显示错误消息时显示错误消息: 在DispatcherServlet中找不到带有URI [/ techy9CustomerService / j_spring_security_check]的HTTP请求的映射,名称为' mvc-dispatcher'
登录表格:
<form:form action="${pageContext.request.contextPath}/j_spring_security_check" data-has-location="true" class="lead-sheet-form" accept-charset="UTF-8" method="post">
<label class="lead-sheet-name-first" align="center" style="margin-top:50px ">
<input style="width:350px" id="lead-sheet-name-first" name="username" required placeholder="user id">
</label>
<label class="lead-sheet-name-first" align="center">
<input type="password" style=" width:350px" id="lead-sheet-name-first" name="password" required placeholder="password" >
</label>
<p align="center">
<button id="loginButton" class="button" style="background-color: rgb(0, 126, 229);border-color: rgb(0, 126, 229)" >Sign in</button>
</p>
<a class="" href="#" style="padding-left: 40px"><font color="#2895F1" size="2px">Forgot your password?</font></a>
</form:form>
弹簧secuirty.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-4.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-4.0.xsd">
<!-- enable use-expressions -->
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/users/**" access="hasRole('ROLE_USER')" />
<!-- access denied page -->
<access-denied-handler error-page="/403" />
<form-login login-page="/home" authentication-failure-url="/home"
default-target-url="/home" username-parameter="username" password-parameter="password" />
<logout logout-success-url="/home" />
<!-- enable csrf protection -->
<csrf />
</http>
<authentication-manager>
<authentication-provider user-service-ref="loginService" />
</authentication-manager>
</beans:beans>
答案 0 :(得分:0)
您是否已在web.xml中发布了SpringSecurityFilterChain?
你必须在web.xml中有类似的东西。否则包括它:
<!-- Spring security filter chain -->
<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>