我有一个Spring项目:
资源文件位于以下位置:子文件夹的src/main/resources/style/.........lots
servlet.xml:
<mvc:annotation-driven/>
<mvc:resources mapping="/resources/**" location="/resources/" />和我的jsp:
<link rel="stylesheet" href="<%=request.getContextPath()%>/resources/style/jquery_ui/css/custom-theme/jquery-ui-1.8.23.custom.css"/>当我浏览到我的视图时,给出了这个链接的位置:
http://localhost:8080/webapp/WEB-INF/classes/style/jquery_ui/css/custom-theme/jquery-ui-1.8.23.custom.css我怎样才能让它正确显示css文件?
发布于 2012-09-09 02:03:07
标准的Maven布局在src/main/webapp/resources中有web资源。src/main/resources更多地用于存储库和Java资源。
使用JSTL core c:url tag可以很容易地在JSP中引用它们。在使用它们时,您不需要担心上下文根。例如:
<link rel="stylesheet" href="<c:url value="/resources/style/jquery_ui/css/custom-theme/jquery-ui-1.8.23.custom.css" />" />库将自动将上下文根添加到此URL。
https://stackoverflow.com/questions/12333020
复制相似问题