Stefan Schmidt opened SPR-7329 and commented
A form backing object annotated with @Pattern as follows:
@Pattern(regexp = "\\b[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}\\b")
private String email;
If a wrong email is presented, the validation fails and the error message ('must match "\b[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}\b"') is presented to the Spring form:errors/ tag. This fails with:
2010-06-28 19:05:16,087 [http-8080-2] ERROR org.springframework.web.servlet.tags.form.ErrorsTag - unknown format type at
java.lang.IllegalArgumentException: unknown format type at
at java.text.MessageFormat.makeFormat(MessageFormat.java:1442)
at java.text.MessageFormat.applyPattern(MessageFormat.java:458)
at java.text.MessageFormat.<init>(MessageFormat.java:368)
at org.springframework.context.support.MessageSourceSupport.createMessageFormat(MessageSourceSupport.java:115)
at org.springframework.context.support.MessageSourceSupport.formatMessage(MessageSourceSupport.java:99)
at org.springframework.context.support.AbstractMessageSource.renderDefaultMessage(AbstractMessageSource.java:275)
at org.springframework.context.support.AbstractMessageSource.getMessage(AbstractMessageSource.java:152)
at org.springframework.context.support.AbstractApplicationContext.getMessage(AbstractApplicationContext.java:1196)
at org.springframework.web.servlet.support.RequestContext.getMessage(RequestContext.java:559)
at org.springframework.web.servlet.support.BindStatus.initErrorMessages(BindStatus.java:177)
at org.springframework.web.servlet.support.BindStatus.getErrorMessages(BindStatus.java:273)
at org.springframework.web.servlet.tags.form.ErrorsTag.exposeAttributes(ErrorsTag.java:173)
at org.springframework.web.servlet.tags.form.AbstractHtmlElementBodyTag.writeTagContent(AbstractHtmlElementBodyTag.java:48)
at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:102)
at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:79)
at org.apache.jsp.tag.web.form.fields.input_tagx.doTag(input_tagx.java:330)
at org.apache.jsp.WEB_002dINF.views.people.create_jspx._jspx_meth_field_005finput_005f0(create_jspx.java:123)
at org.apache.jsp.WEB_002dINF.views.people.create_jspx.access$0(create_jspx.java:104)
at org.apache.jsp.WEB_002dINF.views.people.create_jspx$Helper.invoke0(create_jspx.java:163)
at org.apache.jsp.WEB_002dINF.views.people.create_jspx$Helper.invoke(create_jspx.java:180)
at org.apache.jsp.tag.web.form.create_tagx$Helper.invoke0(create_tagx.java:423)
at org.apache.jsp.tag.web.form.create_tagx$Helper.invoke(create_tagx.java:464)
at org.apache.jsp.tag.web.form.page_tagx._jspx_meth_c_005fif_005f1(page_tagx.java:218)
at org.apache.jsp.tag.web.form.page_tagx.doTag(page_tagx.java:126)
at org.apache.jsp.tag.web.form.create_tagx.doTag(create_tagx.java:197)
at org.apache.jsp.WEB_002dINF.views.people.create_jspx._jspx_meth_form_005fcreate_005f0(create_jspx.java:99)
at org.apache.jsp.WEB_002dINF.views.people.create_jspx._jspService(create_jspx.java:63)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
As confirmation that the problem is the formatting of the error message by the Spring errors tag a change of the @Pattern definition in the form backing object to:
@Pattern(regexp = "\\b[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}\\b", message="email validation failed")
private String email;
With this adjustment (a cleaner error message) all works fine.
Affects: 3.0.3
Issue Links:
- ROO-1039 Using {} in RegExp pattern causes IllegalArgumentException: unknown format type ("is depended on by")
Referenced from: commits 1dce03a
1 votes, 2 watchers
Stefan Schmidt opened SPR-7329 and commented
A form backing object annotated with
@Patternas follows:If a wrong email is presented, the validation fails and the error message ('must match "\b[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}\b"') is presented to the Spring form:errors/ tag. This fails with:
As confirmation that the problem is the formatting of the error message by the Spring errors tag a change of the
@Patterndefinition in the form backing object to:With this adjustment (a cleaner error message) all works fine.
Affects: 3.0.3
Issue Links:
Referenced from: commits 1dce03a
1 votes, 2 watchers