• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Spring MVC - Url Handling Problem

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No ideas??
 
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic