javax validation error code problem
I'm using javax validation anotations and get this odd error
java.lang.IllegalArgumentException: can't parse argument number error.tnimi
java.text.MessageFormat.makeFormat(MessageFormat.java:1339)
java.text.MessageFormat.applyPattern(MessageFormat.java:458)
java.text.MessageFormat.<init>(MessageFormat.java:368)
org.springframework.context.support.MessageSourceSupport.createMessageFormat(MessageSourceSupport.java:115)
org.springframework.context.support.MessageSourceSupport.formatMessage(MessageSourceSupport.java:99)
org.springframework.context.support.AbstractMessageSource.renderDefaultMessage(AbstractMessageSource.java:275)
org.springframework.context.support.AbstractMessageSource.getMessage(AbstractMessageSource.java:152)
org.springframework.context.support.DelegatingMessageSource.getMessage(DelegatingMessageSource.java:71)
org.springframework.context.support.AbstractApplicationContext.getMessage(AbstractApplicationContext.java:1125)
org.springframework.web.servlet.support.RequestContext.getMessage(RequestContext.java:559)
org.springframework.web.servlet.support.BindStatus.initErrorMessages(BindStatus.java:177)
org.springframework.web.servlet.support.BindStatus.getErrorMessages(BindStatus.java:273)
org.springframework.web.servlet.tags.form.ErrorsTag.exposeAttributes(ErrorsTag.java:172)
org.springframework.web.servlet.tags.form.AbstractHtmlElementBodyTag.writeTagContent(AbstractHtmlElementBodyTag.java:48)
org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:91)
org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:78)
org.apache.jsp.WEB_002dINF.jsp.addmaterial_jsp._jspService(addmaterial_jsp.java:579)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
org.apache.jasper.runtime.PageContextImpl.doInclude(PageContextImpl.java:650)
org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:644)
org.apache.tiles.jsp.context.JspTilesRequestContext.include(JspTilesRequestContext.java:103)
org.apache.tiles.jsp.context.JspTilesRequestContext.dispatch(JspTilesRequestContext.java:96)
org.apache.tiles.renderer.impl.UntypedAttributeRenderer.write(UntypedAttributeRenderer.java:61)
org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:103)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:659)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:337)
org.apache.tiles.jsp.taglib.InsertAttributeTag.render(InsertAttributeTag.java:234)
org.apache.tiles.jsp.taglib.InsertAttributeTag.render(InsertAttributeTag.java:211)
org.apache.tiles.jsp.taglib.RenderTag.doEndTag(RenderTag.java:220)
org.apache.jsp.WEB_002dINF.tiles.root_jsp._jspx_meth_tiles_005finsertAttribute_005f1(root_jsp.java:203)
org.apache.jsp.WEB_002dINF.tiles.root_jsp._jspService(root_jsp.java:88)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.tiles.servlet.context.ServletTilesRequestContext.forward(ServletTilesRequestContext.java:241)
org.apache.tiles.servlet.context.ServletTilesRequestContext.dispatch(ServletTilesRequestContext.java:222)
org.apache.tiles.renderer.impl.TemplateAttributeRenderer.write(TemplateAttributeRenderer.java:44)
org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:103)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:659)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:678)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:633)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:322)
org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:100)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1060)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:563)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:343)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.spring开发者_StackOverflowframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:188)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:149)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
org.jasig.cas.client.session.SingleSignOutFilter.doFilter(SingleSignOutFilter.java:110)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
My anotation is
@NotEmpty (message ="{error.tnimi}")
public String getName() {
Should be right. What to do?
By default Spring doesn't configure JSR-303's MessageInterpolator
to use the MessageSource
defined by you, therefore you can't use this syntax to access messages from your own MessageSource
.
The typical approach is to use the default messages codes in your MessageSource
, such as NotEmpty.objectName.name
instead of explicitly speficied codes in message
attribute.
Since Spring 3.0.4 and Hibernate Validator 4.1, you can configure message interpolator to use your message source, see javadoc.
精彩评论