簡體   English   中英

如何使用Spring Security在Spring應用程序的登錄頁面中訪問資源包

[英]How to access resource bundle in login page of spring application using spring security

我想使用標記<spring:message code="login.name" />在登錄頁面中使用資源包,但是由於出現錯誤

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

我在下面提到了這個答案,但它對我不起作用。 直接調用JSP時,可以在Spring中使用Message Resource Bundle嗎?

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

有什么建議嗎? 我認為應該通過控制器路由登錄請求,然后我將能夠訪問資源包,但是該怎么做呢?

將您的login.jsp放在WEB-INF目錄下。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM