• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Spring 3.2.0.M2 : Using Static Resources

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Everyone , I started learning spring framework a month back reading "Spring in Action 3" and Online tutorials, I want to use static resources i.e css and js files.
I am using Eclipse JUNO where if you choose a new project as 'Dynamic Web Project' that's the hierarchy of folders I am talking here.
I have used


the 'resources' folder(placed in parallel to 'WEB-INF' inside 'WebContent' ) containing 'js' , 'css' folder which further contains .js and .css files respectively, these jQuery and Css are used in home.jsp.
I have a mapping as '/app/home' in a controller 'AppController' for a jsp page home.jsp placed in WebContent-->WEB-INF-->view-->jsp-->home.jsp.
another mapping as ' /app/home/userhome' in same controller using same ModelAndMap return type method returning a 'new ModelAndMap("home")' instance.
the problem is the former case works fine but later does not, the browser on viewing the source for the generated html content gives error 404(not found) when the js and css links are clicked.

What I concluded is spring mvc is having some problem with the context path , since it is the difference in mapping which let the dispatcher looking at two different location for the same mapped resource.

here is dispatcher-servlet.xml


web.xml is as


AppController as


here is the snippet of the home.jsp



Can anyone help and tell is there a way we can map and get our static content used without have to worry about context path every time we put a new mapping heirarchy(since the mapping is logical and helps to make a logical hierarchy for a portal or any web service ).

Thanks a lot sparing your time for this.
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try the curl tag. See here:
https://github.com/SpringSource/spring-mvc-showcase/blob/master/src/main/webapp/WEB-INF/views/form.jsp
 
Ackshat Sharma
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bill, It worked when I used

So it works when we specify context attribute too.
 
Don't sweat petty things, or pet sweaty things. But cuddle this tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic