首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在SpringMVC应用程序中集成Twitter引导程序

在SpringMVC应用程序中集成Twitter引导程序
EN

Stack Overflow用户
提问于 2012-10-08 15:41:14
回答 2查看 6K关注 0票数 2

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

问题:

  1. 下载的引导文件夹放在哪里?

到目前为止我所拥有的。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-10-08 16:06:38

我会把这些放在src/main/resources中,而不是在WEB下。这些不需要被保护。

另外,确保按照documentation告诉Spring它们在dispatcher servlet配置文件中的位置。

代码语言:javascript
复制
<mvc:resources mapping="/resources/**" location="/resources/" />

如果您也使用Spring安全性,则需要确保资源不受保护。

代码语言:javascript
复制
<http pattern="/resources/**" security="none"/>
票数 5
EN

Stack Overflow用户

发布于 2012-10-08 15:51:01

您不需要.less文件,除非您计划编译自定义css。Maven项目,通常将它们放在“资源”文件夹中。资源/资产/css和资源/资产/js

在JSP中:

代码语言:javascript
复制
<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"/>

然后在头部标签上

代码语言:javascript
复制
<script src="${pageScope.bootstrapJavascriptUrl}"></script>
<link rel="stylesheet" href="${pageScope.bootstrapStylesheetUrl}"/>
<link rel="stylesheet" href="${pageScope.bootstrapResponsiveStylesheetUrl}"/>

另外,不要忘记将添加到jsp的顶部

代码语言:javascript
复制
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>

在servlet上下文配置(productmgmt-servlet.xml)中,添加行:

代码语言:javascript
复制
<mvc:resources mapping="/resources/**" location="classpath:/"/>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12784992

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档