File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem finding index page under WEB-INF / Spring MVC

 
Mike Gibbs
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to move all my jsps into a folder under WebContents/WEB-INF/view but I keep getting a 404. Going to http://localhost:8080/test-app/ doesn't find my index.jsp under the view folder, but is ok in the WebContent folder. Why might this be?

Folder structure:


dispatcher-servlet.xml



web.xml

 
Sean Clark
Rancher
Posts: 377
Android Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

You should try...
http://localhost:8080/test-app/index it won't find an index.jsp file if you are only pointing at the root...

Sean
 
Mike Gibbs
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sean Clark wrote:Hey,

You should try...
http://localhost:8080/test-app/index it won't find an index.jsp file if you are only pointing at the root...

Sean


That doesn't work either.
 
Mike Gibbs
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, folders under WEB-INF are protected and must be accessed via code.

http://stackoverflow.com/questions/4688841/http-404-problem-jsp-can-not-see-in-web
 
Sean Clark
Rancher
Posts: 377
Android Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

That shouldn't matter, that's why you have created a viewResolver in your spring configuration and why you have used the <mvc:view-controller /> annotation.
There is however another problem in your configuration that is probably the issue, you have not created Spring's servlet in the web.xml you posted. Therefore Spring will never be initialised.

Sean
 
Mike Gibbs
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sean Clark wrote:Hey,

That shouldn't matter, that's why you have created a viewResolver in your spring configuration and why you have used the <mvc:view-controller /> annotation.
There is however another problem in your configuration that is probably the issue, you have not created Spring's servlet in the web.xml you posted. Therefore Spring will never be initialised.

Sean


Hey,

I appreciate your help, I updated my code in the first post.

<mvc:view-controller /> - I use this tag because I used this on placement this summer, and I thought I'd use it again, but I can't seem to set up the application properly with Tomcat, before, I was using Google App Engine.

If I go to my index.jsp by going to http://localhost:8080/test-app/ I get a 404 (Going to http://localhost:8080/ gets me the Tomcat management page).
 
Sean Clark
Rancher
Posts: 377
Android Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

The URL pattern for the servlet is still wrong, it should go from the context root (test-app) so it should be /*.

Sean
 
Mike Gibbs
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sean Clark wrote:Hey,

The URL pattern for the servlet is still wrong, it should go from the context root (test-app) so it should be /*.

Sean


Still doesn't work.
 
Sean Clark
Rancher
Posts: 377
Android Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok got it, should be / and not /*.

I just created a test app with your settings (apart from the sitemesh filter which I commented out and the listener which I did the same as it expects an applicationContext.xml file).

Sean
 
Mike Gibbs
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sean Clark wrote:Ok got it, should be / and not /*.

I just created a test app with your settings (apart from the sitemesh filter which I commented out and the listener which I did the same as it expects an applicationContext.xml file).

Sean


Tried / and not /*, and commented out the sitemesh, restarted the server too. I'm using Tomcat 7, using the Tomcat installaion in Eclipse.

Edit:
Can you upload your test app for me to test please?
 
Sean Clark
Rancher
Posts: 377
Android Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What url are you using?

Sean
 
Mike Gibbs
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sean Clark wrote:What url are you using?

Sean


http://localhost:8080/test-app/
 
Sean Clark
Rancher
Posts: 377
Android Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm out of ideas then, it's certainly working from mine.
Just make sure there are no errors coming up when tomcat starts.

Sorry.
Sean
 
Mike Gibbs
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem solved.
 
Mike Gibbs
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem solved.
 
sunny sand
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we use mvc:view-controller tag for displaying a tiles view.
Eg:If we have a tiles definition of the form <definition name="userLogon.page" template="webapp/app/layout/baseLayoutExterior.jsp" extends="basePageDefinition">
Can we write <mvc:view-controller path="/logon" view-name="userLogon.page"/> in our servlet.xml file.
I am getting an HTTP 404 RESOURCE NOT FOUND ERROR on this whereas a normal hello.jsp page is displayed without problems.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic