- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
使用典型安全性时,注册表单中的错误不会显示在表单中。没有关于哪里出了问题的反馈,只有一个空白的屏幕。
我在这个问题的底部提供了一个空表单的解决方案。
但问题仍然是如何获取表单中显示的绑定(bind)结果验证错误。就像在“创建新用户”表单中一样。
我正在使用添加了 gvNIX 的 Spring 2.0.0.M1!
我已经创建了一个 issue at github
我的问题:是否有一个简单的解决方法来让它工作。
测试脚本:
// Create a new project
project setup --topLevelPackage com.springsource.pizzashop --projectName pizzashop
jpa setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY
entity jpa --class ~.domain.Pizza
field string --fieldName name --notNull --sizeMin 10
field number --fieldName price --notNull --type java.math.BigDecimal
// Adding web layers
web mvc setup
web mvc all --package ~.web
// Adding Spring security
typicalsecurity setup
// Adding JQuery, Datatables and Bootstrap
web mvc jquery setup
web mvc jquery all
web mvc datatables setup
web mvc bootstrap setup
web mvc bootstrap update
更改密码字段的要求长度:
在文件...\src\main\java\com\springsource\pizzashop\domain\User.java
@NotNull
@Size(min = 8) // was (min = 1)
private String password;
在文件 ..\src\main\java\com\springsource\pizzashop\web\UserRegistrationForm.java 中应用与上面相同的更改。
@NotNull
@Size(min = 8) // was (min = 1)
private String password;
在文件 ...\src\main\java\com\springsource\pizzashop\web\SignUpController.java 中添加一行调试信息
@RequestMapping(method = RequestMethod.POST, produces = "text/html")
public String create(@Valid UserRegistrationForm userRegistration, BindingResult result, Model model, HttpServletRequest request) {
validator.validate(userRegistration, result);
System.out.println("Has binding errors: " + result.toString()); // added
if (result.hasErrors()) {
return createForm(model);
} else {
// Rest of the code
当注册表单中的密码字段仅填写一个字母而不是 8 个字母时,Recaptcha 错误,调试行显示以下消息:
Has binding errors: org.springframework.validation.BeanPropertyBindingResult: 3 errors
Field error in object 'userRegistrationForm' on field 'repeatPassword': rejected value [a]; codes [Size.userRegistrationForm.repeatPassword,Size.repeatPassword,Size.java.lang.String,Size]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [userRegistrationForm.repeatPassword,repeatPassword]; arguments []; default message [repeatPassword],2147483647,8]; default message [size must be between 8 and 2147483647]
Field error in object 'userRegistrationForm' on field 'password': rejected value [a]; codes [Size.userRegistrationForm.password,Size.password,Size.java.lang.String,Size]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [userRegistrationForm.password,password]; arguments []; default message [password],2147483647,8]; default message [size must be between 8 and 2147483647]
Error in object 'userRegistrationForm': codes [recaptcha.mismatch.userRegistrationForm,recaptcha.mismatch]; arguments []; default message [null]
这是正确的,但是用户在屏幕上看到的表单中没有显示任何反馈!所以对于用户来说,不清楚哪里出了问题,为什么表单没有保存,但又回来了。用户看到的只是一个没有任何信息的空注册表单。
我期望的是一条消息,就像在“创建新用户”时显示的那样,此密码字段也填充了一个字母。比红色显示的消息:大小必须介于 8 和 2147483647 之间
空屏解决方法: 空屏幕的解决方案是返回到表单,其中包含用户在按下“保存”时提供的信息。这与 Spring Roo/gvNIX 的其他创建和更新方法中的行为相同。
@RequestMapping(method = RequestMethod.POST, produces = "text/html")
public String create(@Valid UserRegistrationForm userRegistration, BindingResult result, Model model, HttpServletRequest request) {
validator.validate(userRegistration, result);
if (result.hasErrors()) {
model.addAttribute("User", userRegistration); // Added: the original info
return "signup/index";
//return createForm(model); // original, commented out.
} else {
这解决了空白屏幕的问题,用户可以看到他/她提供的信息。但是,我仍然没有看到绑定(bind)结果的红色反馈。
我怎样才能让它可见?
最佳答案
这是在 gvNIX 2.0.0.M1 上发现的错误,将在 gvNIX 项目的 future 版本中修复。
要显示这些错误消息,您必须对项目进行以下更改:
在文件 ~/webapp/WEB-INF/tags/jquery/form/create.tagx(第 ~30 行)你必须编辑 form 元素的 cssClass 属性像这样:
<form:form cssClass="form-horizontal validate" ... >
将红色样式添加到错误范围,在文件 ~/webapp/styles/standard.css 中添加以下代码:
.errors {
color: #b94a48;
display: block;
}
要将此选项应用于密码输入,您必须编辑文件 ~/WEB-INF/tags/jquery/form/fields/input.tagx,将所有这些选项添加到密码输入。像这样将它们全部写在 ~112 行:
<form:password class="form-control input-sm" id="_${sec_field}_id" path="${sec_field}" disabled="${disabled}" size="${size}"
data-required="${required}" data-invalid="${field_invalid}" data-missing="${sec_field_required}"
data-regex="${validationRegex}" data-minlength="${min}" data-maxlength="${max}"
data-mindecimal="${decimalMin}" data-maxdecimal="${decimalMax}" value="${value}"/>
请尝试一下,然后告诉我它是否对您有用。
We will take in mind this problems for future versions of gvNIX
希望这对您有所帮助。问候。
关于java - gvNIX 典型安全性 : no feedback in signup form UI of binding errors,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34565674/
有什么方法可以使用常用工具(ffmpeg?mplayer/mencoder?mkvmerge?等)来查找关键帧在给定视频文件中出现的频率? {从而找到最小搜索大小?}这似乎是一个显而易见的统计数据,“
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 2 年前。 Improve
我正在阅读Intel的SSD产品specification。那里有一张桌子说 Latency (typical) read/write < 10 us 但是没有更多细节可以解释这个数字。有人知道“典型
出于好奇:典型的 Linux 发行版中最古老的代码/包是什么?电子书?海湾合作委员会? 最佳答案 Sun RPC 很老了,它在 C 库中: http://blogs.oracle.com/webmin
一个常见的假设是 1/x * x == 1。在符合 IEEE 754 标准的常见硬件上打破这个的最小正整数是多少? 当乘法逆的假设失败时,写得不好的有理算术就会停止工作。由于包括 C 和 C++ 在内
流行手机型号支持的典型触摸点数量是多少?我在基础研究中看到低至 2 和高至 5,但我希望能够将其映射到实际手机和更好的限制! 最佳答案 两部手机的触控点数据: Galaxy S 5 LG
我讨厌讨厌IE!既然我已经咆哮了,我确实需要一些帮助。我这里有这个网站。 http://pearsonlyle.uwpistol.net/galleries/susie-theodorou/edito
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 1
作为来自企业 IT 的 Node.js 初学者,我无法理解 Node.js 用法的某一方面。我将我的问题分为两部分。 问题 1) 严格从可扩展性的角度来看,I/O 密集型 Web 应用程序如何使用 N
我希望我的问题是合法的......我问这个问题是因为在阅读了许多博客,玩了许多示例应用程序和官方 API 1 周后,我仍然很困惑,从哪里开始编码...... 总的来说,就浏览器之间的系统架构而言 W
这是我的汽车类(class): public class Car { private int FGNr; private String name; private String type; priva
我认为我的问题标题清楚地表达了我需要的信息的本质。我用谷歌搜索了 where is the "applies to list" in vba excel以及其中的一些变体,都带有如图所示的引号,这应该
我是一名优秀的程序员,十分优秀!