我开始在SpringMVC中构建基本应用程序。同时,我想使用一些易于设置的UI框架,如Twitter Bootstrap。但是,不知道如何设置它。将Spring Bootstrap集成到SpringMVC应用程序中
问:
- 我在哪里放置下载的引导文件夹?
我有什么事这么远。
我开始在SpringMVC中构建基本应用程序。同时,我想使用一些易于设置的UI框架,如Twitter Bootstrap。但是,不知道如何设置它。将Spring Bootstrap集成到SpringMVC应用程序中
问:
我有什么事这么远。
我会把这些放在src/main/resources下的不是在WEB-INF下。这些不需要保护。
此外,请确保您告诉Spring它们在您的调度程序servlet配置文件中,根据documentation。
<mvc:resources mapping="/resources/**" location="/resources/" />
如果您使用的是Spring安全性,那么您需要确保资源不受保护。
<http pattern="/resources/**" security="none"/>
如果我的资源位于webContent文件夹下,它会工作吗?如果是的话,我怎么能参考它? – larrytech
除非您打算编译自定义css,否则不需要.less文件。 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}"/>
另外,不要忘记添加弹簧的taglib到你的JSP
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
在Spring servlet上下文配置(productmgmt-servlet.xml中)的顶部添加一行:
<mvc:resources mapping="/resources/**" location="classpath:/"/>
我打算这么做,你会告诉我你的使用Bootstrap和Spring MVC的经验如何?问题是在这里http://stackoverflow.com/questions/28732301/whats-the-best-method-to-implement-front-end-for-a-springmvc-application – Jack