spring mvc - No mapping found for HTTP request with URI [/pms/j_spring_security_check] in DispatcherServlet with name 'appServlet' -
i have developed spring application , implement spring security integration login , logout function in it. used spring security xml configuration. when login scheme shows 404 me. console telling me, no mapping found http request uri [/pms/j_spring_security_check] in dispatcherservlet name 'appservlet'
but can not understand error. have missed?
my web.xml
<?xml version="1.0" encoding="utf-8"?> <web-app version="2.5" 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_2_5.xsd"> <!-- definition of root spring container shared servlets , filters --> <!-- creates spring container shared servlets , filters --> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> <!-- 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>/</url-pattern> </servlet-mapping> <context-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/spring/appservlet/spring-security.xml</param-value> </context-param> <!-- spring security --> <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> my controller method :
@requestmapping(value="/login", method = requestmethod.get) public modelandview printwelcome() { modelandview modelandview = new modelandview(); modelandview.addobject("message", "spring security allows you"); modelandview.setviewname("loginform"); homecoming modelandview; } my spring-security.xml :
<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="/loginform"/> <intercept-url pattern="/" access="role_user" /> <form-login login-page="/loginform" default-target-url="/login" always-use-default-target="true" authentication-failure-url="/loginform?login_error=1" /> <logout logout-success-url="/loginform" /> </http> <authentication-manager> <authentication-provider> <user-service> <user name="a2ztechguide" password="123456" authorities="role_user" /> </user-service> </authentication-provider> </authentication-manager> </beans:beans> and of login page :
<body> <table> <tr> <td valign="top"><c:if test="${not empty param.login_error}"> <font color="red"> invalid user name or password, seek again. <br /> <br /> </font> </c:if> <form name="login_form" action="<c:url value='j_spring_security_check'/>" method="post"> <div> <table width="40%" border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="top"> <table border="0" cellspacing="0" cellpadding="4" width="40%"> <tr> <td colspan="2">custom login form <hr width="100%" size="1" noshade align="left"> </td> <td></td> </tr> <tr> <td width="80">username</td> <td valign="top" align="left"><input type='text' id='username' size="30" maxlength="40" name='j_username' value='<c:if test="${not empty param.login_error}"> <c:out value="${spring_security_last_username}"/> </c:if>' /> </td> </tr> <tr> <td width="80">password</td> <td valign="top" align="left"><input type='password' name='j_password' size="30" maxlength="30"></td> </tr> <tr> <td></td> <td><input type="submit" value="submit" /></td> </tr> </table> </td> </tr> </table> </div> </form></td> </tr> </table> </body> please help me.
i solved modifying line declaring custom login form page.
added processing-url="/j_spring_security_check":
<form-login login-page="/login" default-target-url="/admin" login-processing-url="/j_spring_security_check" authentication-failure-url="/login?error" username-parameter="username" password-parameter="password"/> to security-context.xml page
spring-mvc spring-security
No comments:
Post a Comment