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.