如何使用spring security访问Spring应用程序登录页面中的资源包

时间:2012-08-07 11:44:01

标签: java spring spring-security

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

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

我在下面提到了这个答案,但它对我不起作用。 Can I use in Spring the Message Resource Bundle when calling a JSP directly

这是从我的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 />

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

1 个答案:

答案 0 :(得分:0)

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