web.xml
Was following one of training with Spring webmvc 4.2.3, while I'm using Spring webmvc 5.2.3 they suggested to create a form
<form:form modelAttribute="aNewAccount" method="get" action="/accountCreated">
that was causing the "disclose" error.
Altered as below to make it work. Looks like method above was the culprit.
<form:form modelAttribute="aNewAccount" action="accountCreated.html">
in fact, exploring further, method="post" in form annotation would work if properly declared:
@RequestMapping(value="/accountCreated", method=RequestMethod.POST)
I was running the project through Intellij and this got this error after I stopped the running server and restarted it. Killing all the java processes and restarting the app helped.
I had this problem in InteliJ. I went to: Edit -> Configuration -> Deployment -> EditArtifact:
Then there where yellow problems, I just clicked on fix two times and it works. I hope this will help someone.
I had missing application context in the Tomcat Run\Debug configuration:
Adding it, solved the problem and I got the right response instead of "The origin server did not find..."
the problem is in url pattern of servlet-mapping.
<url-pattern>/DispatcherServlet</url-pattern>
let's say our controller is
@Controller
public class HomeController {
@RequestMapping("/home")
public String home(){
return "home";
}
}
when we hit some URL on our browser. the dispatcher servlet will try to map this url.
the url pattern of our serlvet currently is /Dispatcher
which means resources are served from {contextpath}/Dispatcher
but when we request http://localhost:8080/home
we are actually asking resources from /
which is not available.
so either we need to say dispatcher servlet to serve from /
by doing
<url-pattern>/</url-pattern>
our make it serve from /Dispatcher by doing /Dispatcher/*
E.g
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID"
version="3.1">
<display-name>springsecuritydemo</display-name>
<servlet>
<description></description>
<display-name>offers</display-name>
<servlet-name>offers</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>offers</servlet-name>
<url-pattern>/Dispatcher/*</url-pattern>
</servlet-mapping>
</web-app>
and request it with http://localhost:8080/Dispatcher/home
or put just /
to request like
http://localhost:8080/home
I had the same problem and spent about 6 hours to solve it. I didn't find that answer for exactly my situation so maybe it could be useful for somebody.
When I created project, I pointed GroupId in pom.xml as "myproject.myapp" but I didn't create first "prime" package with that name in the project, where would be other packages inside of this main package (like /src/main/app etc). When I created prime package "myproject.myapp" and moved other packages inside of it, the problem was solved.