私は非常に奇妙な春のセキュリティ動作をしています。
セキュリティ構成:
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<http use-expressions="true" >
<intercept-url pattern="/home.jsp" access="permitAll" />
<intercept-url pattern="/*" access="isAuthenticated()"/>
<form-login login-page="/"
authentication-failure-url="/loginFailed" default-target-url="/index" />
<logout logout-success-url="/logOut" />
</http>
<authentication-manager>
<authentication-provider ref="provider" />
</authentication-manager>
</beans:beans>
コントローラ:
@Controller
public class HomeController {
@RequestMapping("/index")
public String success(Model model) {
System.out.println("/index");
return "index";
}
@RequestMapping(value="/loginFailed", method = RequestMethod.GET )
public String loginError(Model model, RedirectAttributes redirectAttributes ) throws Exception {
redirectAttributes.addAttribute("message", "incorrect combination of login and password");
System.out.println("/loginFailed");
return "redirect:home.jsp";
}
@RequestMapping(value="/logOut", method = RequestMethod.GET )
public String logOut(Model model, RedirectAttributes redirectAttributes) throws Exception {
redirectAttributes.addAttribute("message", "success logout");
System.out.println("/logOut");
return "redirect:home.jsp";
}
...
}
URL http://localhost:8080/ui/
(ルートアプリケーションURL)の場合、入力します
最初の活動:
1 正しいパスワードを入力 --> http://localhost:8080/ui/index
ログを見る/index
isAuthenttificated() == true
2 logOut http://localhost:8080/ui/
を押します --> ログは空ですisAuthenttificated() == false
3 正しいパスワードを入力します -->コンソールhttp://localhost:8080/ui/home.jsp?message=success+logout
に表示されます/logOut
isAuthenttificated() == true
4 logOut を押します --> に移動し http://localhost:8080/ui/
、ログは空ですisAuthenttificated() == false
5 正しいパスワードを入力 --> に移動し http://localhost:8080/ui/
、ログは空ですisAuthenttificated() == false
どのスプリング セキュリティがどのコントローラーを使用するかを選択するルールがわかりません。
春は正しいサーブレットを呼び出しますが、間違った URL を使用すると思います。