まず、これが重複している場合は、誰かが指摘してください。しかし、現在、この質問をした人を見つけることができません。私はこの春のセキュリティ構成を持っています:
<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.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<http auto-config="true">
<intercept-url pattern="/admin/**" access="ROLE_ADMIN" />
<form-login login-page="/login.htm" default-target-url="/admin/adminDashboard.htm"
authentication-failure-url="/loginfailed" />
<logout logout-success-url="/logout.htm" />
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="admin" password="123" authorities="ROLE_ADMIN" />
</user-service>
</authentication-provider>
</authentication-manager>
</beans:beans>
つまり、このコントローラー:
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class AdministrationController {
@RequestMapping(value = "/login.htm", method = RequestMethod.GET)
public String login() {
return "login";
}
@RequestMapping(value = "/admin/banAppealsList.htm", method = RequestMethod.GET)
public String banAppealsList() {
return "banAppealsList";
}
@RequestMapping(value = "/admin/adminDashboard.htm", method = RequestMethod.GET)
public String adminDashboard() {
return "adminDashboard";
}
}
ご覧のとおり、/admin/**
URL をインターセプトします。ログに記録すると、ページにリダイレクトされadminDashboard.jsp
ます。しかし、私が直面している問題はadminDashboard.jsp
、資格情報を求められずに自分のページから他の保護されたページにリダイレクトする方法ですか? 基本的に、続行したい場合はbanAppealsList.htm
、資格情報を再度要求されます。
編集:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<!-- The definition of the Root Spring Container shared by all Servlets
and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/root-context.xml
/WEB-INF/security-context.xml
</param-value>
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Define a filter to enable Spring Security, be sure to use the suggested
name 'springSecurityFilterChain' -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>banAppeal.htm</welcome-file>
</welcome-file-list>
<session-config>
<session-timeout>60</session-timeout>
<!-- Obviously, problem was here -->
<cookie-config>
<secure>true</secure>
</cookie-config>
</session-config>
</web-app>