我開始在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