在weblogic上部署时找到resourcebundle

时间:2013-08-15 05:16:15

标签: spring spring-mvc weblogic-10.x

在weblogic上部署spring应用程序后,在尝试加载jsp时遇到以下错误:

javax.servlet.jsp.JspTagException: No message found under code 'label.firstname' for locale 'en_US'.

我做错了什么?

JSP:

<form:form method="post" action="add.html" commandName="contact">

    <table>
    <tr>
        <td><form:label path="firstname"><spring:message code="label.firstname"/></form:label></td>
        <td><form:input path="firstname" /></td>
    </tr>
.....
</table> 
</form:form>

春天背景:

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

网络应用(战争)结构

META-INF/
META-INF/MANIFEST.MF
WEB-INF/
WEB-INF/classes/
WEB-INF/classes/messages_en.properties
WEB-INF/classes/org/
WEB-INF/classes/org/spring/
WEB-INF/classes/org/spring/controller/
WEB-INF/classes/org/spring/controller/ContactController.class
WEB-INF/classes/org/spring/dao/
WEB-INF/classes/org/spring/dao/ContactDAO.class
WEB-INF/classes/org/spring/dao/ContactDAOImpl.class
WEB-INF/classes/org/spring/entity/
WEB-INF/classes/org/spring/entity/Contact.class
WEB-INF/classes/org/spring/service/
.....

1 个答案:

答案 0 :(得分:0)

basename属性是相对于war root(不是classpath)的,因此你应该把它放在<war_root>/messages_en.properties上。如果您不希望提供属性文件,最好将其放在<war_root>/WEB-INF/messages_en.properties上,并将basename属性设置为WEB-INF/messages