Java,Spring Internationalization(I18N)无法正常工作

时间:2011-08-14 19:16:55

标签: java spring internationalization

我正试图用I18N改变我的春季项目语言。

我在spring-servlet.xml中的I18N配置:

<bean id="messageSource"
    class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basename" value="classpath:messages" />
    <property name="defaultEncoding" value="UTF-8"/>
</bean>

<bean id="localeChangeInterceptor"
    class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
    <property name="paramName" value="lang" />
</bean>

<bean id="localeResolver"
    class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
    <property name="defaultLocale" value="en"/>
</bean>

<bean id="handlerMapping"
    class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
    <property name="interceptors">
        <ref bean="localeChangeInterceptor" />
    </property>
</bean>

所以现在我有2个名为的文件:

  1. messages_en.properties
  2. messages_ee.properties
  3. 他们在我的war / WEB-INF / resources文件夹

    这是我的JSP文件的一部分(当我删除它,一切正常):

    <h3><spring:message code="label.title" /></h3>
    

    这是我的messages_ee.properties文件:

    label.firstname=Eesnimi
    label.lastname=Perekonnanimi
    label.email=Email
    label.telephone=Telefon
    label.addcontact=Lisa kontakt
    
    label.menu=Menuu
    label.title=Kontaktihaldur
    

    你可以清楚地看到,我为locale'ee'提供了label.title。可能有什么问题,它不承认它。或者,甚至可能找不到文件?

    找不到locale'ee'的label.title,为什么?

    当我尝试浏览某个网页时,它说它在属性文件中找不到任何包含此错误的内容:

    HTTP Status 500 -
    
    type Exception report
    
    message
    
    description The server encountered an internal error () that prevented it from fulfilling this request.
    
    exception
    
    org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 1
    
    1: <jsp:forward page="contact.html"></jsp:forward>
    
    
    Stacktrace:
        org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:567)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:456)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    root cause
    
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.apache.tiles.impl.CannotRenderException: ServletException including path '/WEB-INF/jsp/layout.jsp'.
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656)
        org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:745)
        org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:716)
        org.apache.jsp.index_jsp._jspService(index_jsp.java:63)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    root cause
    
    org.apache.tiles.impl.CannotRenderException: ServletException including path '/WEB-INF/jsp/layout.jsp'.
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:692)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:644)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:627)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:321)
        org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:124)
        org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
        org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
        org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
        org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
        org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:745)
        org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:716)
        org.apache.jsp.index_jsp._jspService(index_jsp.java:63)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    root cause
    
    org.apache.tiles.util.TilesIOException: ServletException including path '/WEB-INF/jsp/layout.jsp'.
        org.apache.tiles.servlet.context.ServletUtil.wrapServletException(ServletUtil.java:241)
        org.apache.tiles.servlet.context.ServletTilesRequestContext.forward(ServletTilesRequestContext.java:243)
        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:106)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:670)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:690)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:644)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:627)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:321)
        org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:124)
        org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
        org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
        org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
        org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
        org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:745)
        org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:716)
        org.apache.jsp.index_jsp._jspService(index_jsp.java:63)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    root cause
    
    org.apache.tiles.util.TilesIOException: JSPException including path '/WEB-INF/jsp/header.jsp'.
        org.apache.tiles.servlet.context.ServletUtil.wrapServletException(ServletUtil.java:241)
        org.apache.tiles.jsp.context.JspTilesRequestContext.include(JspTilesRequestContext.java:105)
        org.apache.tiles.jsp.context.JspTilesRequestContext.dispatch(JspTilesRequestContext.java:96)
        org.apache.tiles.renderer.impl.TemplateAttributeRenderer.write(TemplateAttributeRenderer.java:44)
        org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
        org.apache.tiles.renderer.impl.ChainedDelegateAttributeRenderer.write(ChainedDelegateAttributeRenderer.java:76)
        org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:670)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:336)
        org.apache.tiles.template.InsertAttributeModel.renderAttribute(InsertAttributeModel.java:210)
        org.apache.tiles.template.InsertAttributeModel.end(InsertAttributeModel.java:126)
        org.apache.tiles.jsp.taglib.InsertAttributeTag.doTag(InsertAttributeTag.java:311)
        org.apache.jsp.WEB_002dINF.jsp.layout_jsp._jspx_meth_tiles_005finsertAttribute_005f1(layout_jsp.java:142)
        org.apache.jsp.WEB_002dINF.jsp.layout_jsp._jspService(layout_jsp.java:78)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        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:106)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:670)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:690)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:644)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:627)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:321)
        org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:124)
        org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
        org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
        org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
        org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
        org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:745)
        org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:716)
        org.apache.jsp.index_jsp._jspService(index_jsp.java:63)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    root cause
    
    javax.servlet.ServletException: javax.servlet.jsp.JspTagException: No message found under code 'label.title' for locale 'ee'.
        org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:911)
        org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)
        org.apache.jsp.WEB_002dINF.jsp.header_jsp._jspService(header_jsp.java:83)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:927)
        org.apache.jasper.runtime.PageContextImpl.doInclude(PageContextImpl.java:684)
        org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:678)
        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.TemplateAttributeRenderer.write(TemplateAttributeRenderer.java:44)
        org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
        org.apache.tiles.renderer.impl.ChainedDelegateAttributeRenderer.write(ChainedDelegateAttributeRenderer.java:76)
        org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:670)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:336)
        org.apache.tiles.template.InsertAttributeModel.renderAttribute(InsertAttributeModel.java:210)
        org.apache.tiles.template.InsertAttributeModel.end(InsertAttributeModel.java:126)
        org.apache.tiles.jsp.taglib.InsertAttributeTag.doTag(InsertAttributeTag.java:311)
        org.apache.jsp.WEB_002dINF.jsp.layout_jsp._jspx_meth_tiles_005finsertAttribute_005f1(layout_jsp.java:142)
        org.apache.jsp.WEB_002dINF.jsp.layout_jsp._jspService(layout_jsp.java:78)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        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:106)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:670)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:690)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:644)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:627)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:321)
        org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:124)
        org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
        org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
        org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
        org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
        org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:745)
        org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:716)
        org.apache.jsp.index_jsp._jspService(index_jsp.java:63)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    root cause
    
    javax.servlet.jsp.JspTagException: No message found under code 'label.title' for locale 'ee'.
        org.springframework.web.servlet.tags.MessageTag.doStartTagInternal(MessageTag.java:184)
        org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:79)
        org.apache.jsp.WEB_002dINF.jsp.header_jsp._jspx_meth_spring_005fmessage_005f0(header_jsp.java:102)
        org.apache.jsp.WEB_002dINF.jsp.header_jsp._jspService(header_jsp.java:69)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:927)
        org.apache.jasper.runtime.PageContextImpl.doInclude(PageContextImpl.java:684)
        org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:678)
        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.TemplateAttributeRenderer.write(TemplateAttributeRenderer.java:44)
        org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
        org.apache.tiles.renderer.impl.ChainedDelegateAttributeRenderer.write(ChainedDelegateAttributeRenderer.java:76)
        org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:670)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:336)
        org.apache.tiles.template.InsertAttributeModel.renderAttribute(InsertAttributeModel.java:210)
        org.apache.tiles.template.InsertAttributeModel.end(InsertAttributeModel.java:126)
        org.apache.tiles.jsp.taglib.InsertAttributeTag.doTag(InsertAttributeTag.java:311)
        org.apache.jsp.WEB_002dINF.jsp.layout_jsp._jspx_meth_tiles_005finsertAttribute_005f1(layout_jsp.java:142)
        org.apache.jsp.WEB_002dINF.jsp.layout_jsp._jspService(layout_jsp.java:78)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        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:106)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:670)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:690)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:644)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:627)
        org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:321)
        org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:124)
        org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
        org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
        org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
        org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
        org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:745)
        org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:716)
        org.apache.jsp.index_jsp._jspService(index_jsp.java:63)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    note The full stack trace of the root cause is available in the Apache Tomcat/7.0.20 logs.
    
    Apache Tomcat/7.0.20
    

    我尽量提供尽可能多的信息并详细介绍。请随时询问更多信息/代码。

3 个答案:

答案 0 :(得分:3)

您配置了消息源以在类路径中查找属性文件(“classpath:messages”)。您使用“/ WEB-INF / resources”的文件夹不是默认情况下类路径的一部分。所以我的猜测是,如果你将属性文件移动到/ WEB-INF / classes(在提取的战争中)它应该工作。或者您尝试将basename的属性从“classpath:messages”更改为“/ WEB-INF / resources / messages”。但我不确定这是否有效。

答案 1 :(得分:1)

将messages.properties文件放在src文件夹中。

答案 2 :(得分:0)

我正在使用netbeans。为了解决这个问题,我已将.properties个文件从SpringDemo\src\java\resources\messages_en.properties移至SpringDemo\src\java\messages_en.properties,并且有效。

现在部署后,它将资源文件直接打包在classes文件夹而不是classes / resources文件夹中。