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 时,我都会收到以下错误。任何想法为什么它在“上午/下午”部分有问题?

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

尝试这个:

                     <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 a”,而不是“h:mm:ss a”。

于 2013-08-12T17:31:40.157 回答
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:00 AM”而不是“8: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 回答