0

我想使用标签在登录页面中使用资源包,<spring:message code="login.name" />但出现错误

No message found under code 'login.name' for locale 'en_US'. 

我在下面提到了这个答案,但它对我不起作用。 直接调用JSP时我可以在Spring中使用消息资源包吗

这是从我的 spring security.xml 中截取的示例

<sec:global-method-security pre-post-annotations="enabled" />

    <sec:http pattern="/css/**" security="none"/>
    <sec:http pattern="/images/**" security="none"/>
    <sec:http pattern="/js/**" security="none"/>
    <sec:http pattern="/index.jsp" security="none"/>
    <!-- <sec:http pattern="/app/addNewUser.json" security="none"/> -->
    <sec:http pattern="/login.jsp" security="none"/>
    <sec:http use-expressions="true">

        <!--
             Allow all other requests. In a real application you should
             adopt a whitelisting approach where access is not allowed by default
          -->
        <sec:intercept-url pattern="/**" access="isAuthenticated()" />
        <sec:form-login login-page='/login.jsp'
          authentication-failure-url="/login.jsp?login_error=1"
          default-target-url="/index.jsp" />
        <sec:logout logout-success-url="/login.jsp" delete-cookies="JSESSIONID"/>
        <sec:remember-me />

有什么建议吗?我认为登录请求应该通过控制器路由,然后我将能够访问资源包,但如何做到这一点?

4

1 回答 1

0

将您的 login.jsp 放在 WEB-INF 目录下。

于 2012-08-07T11:51:03.387 回答