0

在 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>

Web-app(war) 结构

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/
.....
4

1 回答 1

0

basename 属性是相对于战争根(不是类路径),因此你应该把它放在<war_root>/messages_en.properties. 如果您不希望提供属性文件,最好将其放入并将<war_root>/WEB-INF/messages_en.propertiesbasename 属性设置为WEB-INF/messages

于 2013-08-15T06:14:20.310 回答