No mapping found for HTTP request with URI [/app/j

2019-07-24 23:11发布

问题:

I added this login link to my Spring app:

<a href="<spring:url value="/j_spring_security_login" htmlEscape="true" />">
Sign In
</a>

My assumption was that because this is a built-in tag for accessing the login page, Spring would know how to associate this with an appropriate handler without me having to specify it explicitly.

However, it generates the following error:

org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI 
[/app/j_spring_security_login] in DispatcherServlet with name 'dispatcher'

What's the appropriate way to define the handler for this URL?

回答1:

/j_spring_security_login is a special Spring Security's url, so it's handled by the Spring Security filter and you don't need to define any other handler for it. Just check that you have a properly configured and mapped Spring Security filter, as described here.



回答2:

Do you have a servlet named "dispatcher" that maps to DispatcherServlet in your web.xml? If not, do add it in.

If that's not the case, check out this entry at the Spring forum. You aren't the first person with this problem.