| Author |
No mapping found for HTTP request with URI - Why erreur404
|
fabian verbeek
Ranch Hand
Joined: Oct 20, 2012
Posts: 52
|
|
Hi,
I'm starting to learn spring and for this i tried the hello world.
Unfortunately i've an error404 when i attempt to load my hello.jsp
here is my pom.xml:
my web.xml
my spring-servlet.xml
my controller:
here is my index.jsp thant can call hello.jsp
So when i click on the link i've an error404 and the console return this:
No mapping found for HTTP request with URI [/tutoSpringMavenHibernate/hello.html] in DispatcherServlet with name 'spring'
thanks for your help
|
 |
Kr. Pallav
Ranch Hand
Joined: Mar 06, 2010
Posts: 32
|
|
|
Change to
|
~|>@//@\/~
Kumar Pallav
-------------------
SCJP 5: 86 %, SCWCD: 91%
|
 |
fabian verbeek
Ranch Hand
Joined: Oct 20, 2012
Posts: 52
|
|
|
I've already tested this but still the same error
|
 |
Kr. Pallav
Ranch Hand
Joined: Mar 06, 2010
Posts: 32
|
|
Add
to xml and check if your jsp hello.jsp is inside WEB-INF/jsp folder
|
 |
fabian verbeek
Ranch Hand
Joined: Oct 20, 2012
Posts: 52
|
|
hi,
i added the line : <context:annotation-config />
before the line: <context:component-scan base-package="com.tutoSpringMavenHibernate.controller" /> in my spring-servlet.xml
My page hello.jsp is well under WEB-INF/jsp
If i try to load it with welcome-file in web.xml it works
Somebody has an other idea :-s
thanks for your help
|
 |
Kr. Pallav
Ranch Hand
Joined: Mar 06, 2010
Posts: 32
|
|
In web.xml
Change is
<url-pattern>*.html</url-pattern>
|
 |
fabian verbeek
Ranch Hand
Joined: Oct 20, 2012
Posts: 52
|
|
unfortunately it doesn't work again :-(
Does it come from my dependencies in my pom?
still again the error404
thanks and hope makes it work
|
 |
fabian verbeek
Ranch Hand
Joined: Oct 20, 2012
Posts: 52
|
|
i'm really disapointed with this error :-s
Nobody has a solution to make it works or a tutorial
thanks
|
 |
Bill Gorder
Bartender
Joined: Mar 07, 2010
Posts: 1282
|
|
You have a couple problems. You are creating the context twice once for the webcontext (defaults to servletName-servlet.xml if you don't have it defined) and you are defining a root context using the same configuration.
Take a look at this:
In the example I have explicitly defined the name of the dispatcher servlet context. If I don't do that it will look using the convention I explained above. In your case you are using the exact same configuration for creating 2 contexts. Either use 2 separate ones and leave your root-context empty for now or you can opt out of having to have a separate servlet context by leaving the tag empty like this
Also add this to your spring.xml config file (including the mvc namespace at the top)
finally make sure you are accessing it using the correct context root. (don't include the context root as part of your mapping in your controller handler as someone else already mentioned)
|
[How To Ask Questions][Read before you PM me]
|
 |
Bill Gorder
Bartender
Joined: Mar 07, 2010
Posts: 1282
|
|
Also you can remove
it is unnecessary if you are using component scan.
|
 |
fabian verbeek
Ranch Hand
Joined: Oct 20, 2012
Posts: 52
|
|
thanks a lot for your explanation.
i tested but i've always the same error404 :-s
here is my new web.xml:
my spring-servlet.xml under WEB-INF/spring/appServlet
my root-context.xml under WEB-INF/spring
my index.jsp under the root path and my hello.sp under WEB-INF/jsp
I call it from index.jsp on calling it with: <a href="hello.html">Say Hello</a>
finally here is my controller:
What is my mistake? i'm a php developer and it's really difficult to me to understand.
thans for your helps
|
 |
fabian verbeek
Ranch Hand
Joined: Oct 20, 2012
Posts: 52
|
|
it should come an issue with maven or eclipse because i tried without maven and in including the necessary jar in lib folder of tomcat it works.
Here is the lib i used:
commons-logging.jar
org.springframework.asm-3.1.2.RELEASE.jar
org.springframework.beans-3.1.2.RELEASE.jar
org.springframework.context-3.1.2.RELEASE.jar
org.springframework.core-3.1.2.RELEASE.jar
org.springframework.expression-3.1.2.RELEASE.jar
org.springframework.web.servlet-3.1.2.RELEASE.jar
org.springframework.web-3.1.2.RELEASE.jar
javax.servlet.jsp.jstl-1.2.1.jar
thanks for your helps
|
 |
 |
|
|
subject: No mapping found for HTTP request with URI - Why erreur404
|
|
|