This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Spring and the fly likes Spring 3.2.0.M2 : Using Static Resources Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring 3.2.0.M2 : Using Static Resources" Watch "Spring 3.2.0.M2 : Using Static Resources" New topic
Author

Spring 3.2.0.M2 : Using Static Resources

Ackshat Sharma
Greenhorn

Joined: Sep 03, 2011
Posts: 22
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.
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1652
    
    7

Try the curl tag. See here:
https://github.com/SpringSource/spring-mvc-showcase/blob/master/src/main/webapp/WEB-INF/views/form.jsp


[How To Ask Questions][Read before you PM me]
Ackshat Sharma
Greenhorn

Joined: Sep 03, 2011
Posts: 22
Thanks Bill, It worked when I used

So it works when we specify context attribute too.
 
GeeCON Prague 2014
 
subject: Spring 3.2.0.M2 : Using Static Resources