Поскольку я изучаю безопасность springs, я пробовал свой первый пример ниже, и он дает мне ошибку 404. Пожалуйста, найдите файл конфигурации безопасности нижеВесенняя безопасность не загружается страница, дающая 404
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:security="http://www.springframework.org/schema/security"
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">
<security:http auto-config="true">
<security:intercept-url pattern="/hello"
access="ROLE_SCARVAREZ_MEMBER" />
</security:http>
<security:authentication-manager>
<security:authentication-provider>
<security:user-service>
<security:user authorities="ROLE_SCARVAREZ_MEMBER"
name="car" password="scarvarez" />
<security:user authorities="ROLE_SCARVAREZ_MEMBER"
name="mon" password="scarvarez" />
<security:user authorities="ROLE_SCARVAREZ_MEMBER"
name="bea" password="scarvarez" />
<security:user authorities="ROLE_SCARVAREZ_MEMBER"
name="andr" password="scarvarez" />
</security:user-service>
</security:authentication-provider>
</security:authentication-manager>
</beans>
Позже у меня есть сервлет следующим
package com.security.test;
import java.io.IOException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet(urlPatterns = { "/hello" })
public class HelloWorldServlet extends HttpServlet {
private static final long serialVersionUID = 2218168052197231866L;
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) {
try {
response.getWriter().write("Hello World");
} catch (IOException e) {
e.printStackTrace();
}
}
}
Все, что здесь идет хорошо, за исключением, когда я войти в систему, а не привет мир это дает мне 404. Ничто не присутствует на консоли tomcat как таковой. Просто хотел узнать, что может быть с этим?
Edit: - Пожалуйста, найдите мой web.xml
файл
<web-app>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext-security.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>
</web-app>
Почему вы используете 'HttpServlet' весной? – Andremoniy
Это URL '/ hello', который я назвал. Это тот же URL-адрес, который вызывает и вводит в систему и после успеха, вызывает Hello World – Nilesh
@Andremoniy: Может также использовать '@ Controller', но будет ли это проблемой? – Nilesh