我从用SpringMVC构建基本应用程序开始。同时,我想使用一些易于安装的UI框架,比如Twitter Bootstrap。但是,不知道怎么设置它。
问题:



到目前为止我所拥有的。
发布于 2012-10-08 16:06:38
我会把这些放在src/main/resources中,而不是在WEB下。这些不需要被保护。
另外,确保按照documentation告诉Spring它们在dispatcher servlet配置文件中的位置。
<mvc:resources mapping="/resources/**" location="/resources/" />如果您也使用Spring安全性,则需要确保资源不受保护。
<http pattern="/resources/**" security="none"/>发布于 2012-10-08 15:51:01
您不需要.less文件,除非您计划编译自定义css。Maven项目,通常将它们放在“资源”文件夹中。资源/资产/css和资源/资产/js
在JSP中:
<spring:url scope="page" var="bootstrapStylesheetUrl" value="/resources/assets/css/bootstrap.css"/>
<spring:url scope="page" var="bootstrapResponsiveStylesheetUrl" value="/resources/assets/css/bootstrap-responsive.css"/>
<spring:url scope="page" var="bootstrapJavascriptUrl" value="/resources/assets/js/bootstrap.js"/>然后在头部标签上
<script src="${pageScope.bootstrapJavascriptUrl}"></script>
<link rel="stylesheet" href="${pageScope.bootstrapStylesheetUrl}"/>
<link rel="stylesheet" href="${pageScope.bootstrapResponsiveStylesheetUrl}"/>另外,不要忘记将添加到jsp的顶部
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>在servlet上下文配置(productmgmt-servlet.xml)中,添加行:
<mvc:resources mapping="/resources/**" location="classpath:/"/>https://stackoverflow.com/questions/12784992
复制相似问题