Spring maven , access CSS/JS files

I have a Spring project:

Resource files are under : src/main/resources/style/.........lots of subfolders

servlet.xml:

    <mvc:annotation-driven/>
<mvc:resources mapping="/resources/**" location="/resources/" />

and my jsp:

<link rel="stylesheet" href="<%=request.getContextPath()%>/resources/style/jquery_ui/css/custom-theme/jquery-ui-1.8.23.custom.css"/>

When I browse to my view, gives this link as location:

http://localhost:8080/webapp/WEB-INF/classes/style/jquery_ui/css/custom-theme/jquery-ui-1.8.23.custom.css

How can I get it to show css file correctly?

Answers


The standard Maven layout has web resources located in src/main/webapp/resources. The src/main/resources is more for library and Java resources.

Referencing them in your JSP is easily done with the JSTL core c:url tag. You don't need to worry about context root when using these. For example:

<link rel="stylesheet" href="<c:url value="/resources/style/jquery_ui/css/custom-theme/jquery-ui-1.8.23.custom.css" />" />

The library will automatically prepend the context root to this URL.


Need Your Help

Is there an advantage to use a Synchronized Method instead of a Synchronized Block?

java multithreading concurrency synchronized

Can any one tell me the advantage of synchronized method over synchronized block with an example?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.