0

Spring 3.1.1.RELEASE を使用しています。次の属性を持つモデルがあります

@DateTimeFormat(pattern = "h:mm:ss a")
private java.util.Date meetingTime;

私のJSPでは、

                        <form:select path="meetingTime">
                            <form:option value="8:00 AM" name="8:00 AM" />
                        </form:select>

ただし、JSP にアクセスするたびに、次のエラーが発生します。時間の「AM/PM」部分に問題があるのはなぜですか?

java.lang.IllegalArgumentException: Invalid format: "8:00 AM" is malformed at " AM"
    org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:683)
    org.springframework.format.datetime.joda.DateTimeParser.parse(DateTimeParser.java:46)
    org.springframework.format.datetime.joda.DateTimeParser.parse(DateTimeParser.java:1)
    org.springframework.format.support.FormattingConversionService$ParserConverter.convert(FormattingConversionService.java:173)
    org.springframework.format.support.FormattingConversionService$AnnotationParserConverter.convert(FormattingConversionService.java:265)
    org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:35)
    org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:171)
    org.springframework.core.convert.support.ConvertingPropertyEditorAdapter.setAsText(ConvertingPropertyEditorAdapter.java:59)
    org.springframework.web.servlet.tags.form.SelectedValueComparator.exhaustiveCompare(SelectedValueComparator.java:189)
    org.springframework.web.servlet.tags.form.SelectedValueComparator.isSelected(SelectedValueComparator.java:103)
    org.springframework.web.servlet.tags.form.OptionTag.isSelected(OptionTag.java:248)
    org.springframework.web.servlet.tags.form.OptionTag.renderOption(OptionTag.java:212)
    org.springframework.web.servlet.tags.form.OptionTag.renderDefaultContent(OptionTag.java:154)
    org.springframework.web.servlet.tags.form.AbstractHtmlElementBodyTag.doEndTag(AbstractHtmlElementBodyTag.java:69)
    org.apache.jsp.WEB_002dINF.views.class_.add_jsp$Helper.invoke0(add_jsp.java:779)
    org.apache.jsp.WEB_002dINF.views.class_.add_jsp$Helper.invoke(add_jsp.java:868)
    org.apache.jsp.tag.web.simplePage_tag.doTag(simplePage_tag.java:205)
    org.apache.jsp.WEB_002dINF.views.class_.add_jsp._jspService(add_jsp.java:123)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
    org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:322)
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:182)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:184)
    org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:155)
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
4

2 に答える 2

0

属性「ラベル」を使用してみてください: http://static.springsource.org/spring/docs/2.0.x/reference/spring-form.tld.html#spring-form.tld.option そして、時間形式があることに注意してください: @DateTimeFormat(pattern = "h:mm:ss a") なので、"8:00 AM" の代わりに "8:00:00 AM" を使用します。

<form:select path="meetingTime">
   <form:option value="8:00:00 AM" label="8:00 AM" />
</form:select>
于 2013-08-12T18:13:34.037 に答える
0

これを試して:

                     <form:select path="meetingTime">
                        <form:option value="8:00 AM">8:00 AM</form:option>
                     </form:select>

「8:00 AM」はオプションの名前ではありません。表示したい値とテキストです。

また、「8:00 a」のフォーマット仕様は「h:mm:ss a」ではなく「h:mm a」だと思います。

于 2013-08-12T17:31:40.157 に答える