aspose file tools*
The moose likes Spring and the fly likes Spring MVC - Url Handling Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring MVC - Url Handling Problem" Watch "Spring MVC - Url Handling Problem" New topic
Author

Spring MVC - Url Handling Problem

Talha Kabakus
Greenhorn

Joined: Feb 27, 2010
Posts: 23
Hello to everyone,

I'm taking URL handling problem as I wrote. I'm newbee at Spring, so I'm waiting your helps and patients.

When I try to launch http://localhost:8090/local/jsp/firstPage.htm or http://localhost:8090/local/firstPage.htm I can't launch my "firstPage.jsp" file which is under the "jsp" folder in the "WEB-INF" folder.

I'll be happy if someone helps me.
Thanks in advance.

Here's my congifuration files :

web.xml



webmvc-servlet.xml



applicationContext.xml



Controller



And my jsp page

Talha Kabakus
Greenhorn

Joined: Feb 27, 2010
Posts: 23
No ideas??
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 538

First, in your web.xml, you have mapped all the .htm requests to spring dispatcher servlet, in webmvc-servlet.xml, you have given *.htm, *.html, *.jsp and *.ajax to localcontroller, there is no way that other requests except *.htm invokes the webmvc-servlet.xml and in webmvc-servlet.xml, you cant have *.htm, you have to be specific..
Talha Kabakus
Greenhorn

Joined: Feb 27, 2010
Posts: 23
Prasad Krishnegowda wrote:First, in your web.xml, you have mapped all the .htm requests to spring dispatcher servlet, in webmvc-servlet.xml, you have given *.htm, *.html, *.jsp and *.ajax to localcontroller, there is no way that other requests except *.htm invokes the webmvc-servlet.xml and in webmvc-servlet.xml, you cant have *.htm, you have to be specific..

OK, so what do you recommend to me? I want to map all .htm, .ajax, .jsp requests to localController. So should I remove .htm mapping from spring dispatcher servlet? Or?
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 538

If you want to do that, you can have mapping for more than one url pattern for spring dispatcher servlet.. but that's not recommended.. Can you please explain us what you are trying to do and how you are thinking to use spring MVC module..
Talha Kabakus
Greenhorn

Joined: Feb 27, 2010
Posts: 23
Well, first of all thank you so much for your interest. I want to use Spring MVC in my project to catch all my jsp pages while calling .htm. And I also want to catch all .ajax requests. That's all I want. I can take your recommendations to do this. Which Spring MVC configuration model is the best for me? XML based or annotation based? And I want to learn my configuration mistakes?

Thanks in advance, I really need your helps.

With regards and greetings,
Talha
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 538

mapping .htm to dispatcher servlet is fine, but still i am not convinced on why you want to catch .ajax requests, Do you want your spring controller to handle ajax requests? If yes, also, no need to map .ajax requests, there are other better way to do that.. If answer is no, can you please explain me the reason behind to map .ajax to spring dispatcher servlet.. If you ask me, i go with xml configuration approach, but there are people who may like annotation based..

P:S: If you have any doubts you can post it here, we will try our level best to help you..
Happy learning..
Talha Kabakus
Greenhorn

Joined: Feb 27, 2010
Posts: 23
Thanks for your kind reply Prasad.

I use ajax requests because I develop web projects so I use many ajax requests, I need to catch them. For example when user click an item in the list, when I need to display its details I do this with an ajax request, etc. OK I can start with XML based configuration, so what is my mistake or absent in the configurations as I wrote above? Can you correct my configurations?
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 538

In your web.xml, if you have mapped *.htm and *.ajax requests to spring dispatcher servlet.. In the dispatcher-servlet.xml, you should have specific mapping like, registration.htm and displayDetails.ajax and map those to their corresponding beans, this is what is missing in your configuration file, currently dispatcher-servlet has generic mappings like *.htm, *.ajax..
Talha Kabakus
Greenhorn

Joined: Feb 27, 2010
Posts: 23
Prasad Krishnegowda wrote:In your web.xml, if you have mapped *.htm and *.ajax requests to spring dispatcher servlet.. In the dispatcher-servlet.xml, you should have specific mapping like, registration.htm and displayDetails.ajax and map those to their corresponding beans, this is what is missing in your configuration file, currently dispatcher-servlet has generic mappings like *.htm, *.ajax..

Thanks for your reply but I think I've configured it with declaring the bean internal path method name resolver 'localControllerMethodNameResolver'.

I don't want to declare each ajax or htm request individually.. So I used this method.. Isn't it true?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring MVC - Url Handling Problem