Как раз 2 дня назад занимался этим же. Все делается довольно несложно. Вот мой вариант: web.xml
| Код | <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <!-- Spring Security --> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/security-applicationContext.xml </param-value> </context-param>> <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> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- Servlets --> <servlet> <servlet-name>spring</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>documentService</servlet-name> <servlet-class>ru.arhtorg.docstore.server.services.DocumentServiceImpl</servlet-class> </servlet> <servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>/documentService</url-pattern> </servlet-mapping> <!-- Default page to serve --> <welcome-file-list> <welcome-file>DocStore.html</welcome-file> </welcome-file-list> </web-app>
|
security-applicationContext.xml
| Код | <?xml version="1.0" encoding="UTF-8"?> <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-2.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd"> <global-method-security secured-annotations="enabled"> </global-method-security> <http> <intercept-url pattern ="/*Service" access="ROLE_SUPERVISOR, ROLE_USER"/> <intercept-url pattern ="/docstore/*" access="ROLE_SUPERVISOR, ROLE_USER"/> <intercept-url pattern ="/*.html" access="ROLE_SUPERVISOR, ROLE_USER"/> <form-login login-page="/jsp/login.jsp" default-target-url="/DocStore.html" authentication-failure-url="/jsp/login.jsp?login_error=1"/> </http> <authentication-provider> <user-service> <user name="admin" password="password" authorities="ROLE_SUPERVISOR, ROLE_ADMIN, ROLE_USER, ROLE_TELLER" /> </user-service> </authentication-provider> </beans:beans>
|
Добавлено через 1 минуту и 57 секунд ЗЫ. В 17й строке файла безопасности у вас комментарий вроде бы как не закрытый. |