Spring MVC 使用 静态资源
来源:互联网 发布:手机设计图纸软件 编辑:程序博客网 时间:2024/06/08 12:57
- 页面引入jstl标签库
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
- 项目的目录如下图所示:
- Spring Mvc 的配置文件写成下面这样子
- 注意几个地方:
- xmlns:mvc
- xsi:schemaLocation
- mvc:resources
- mvc:annotation-driven
<?xml version= "1.0" encoding ="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<context:component-scan base-package="com.forum.www.controller" />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/views/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<mvc:resources mapping="/jquery/**" location="/resource/jquery/"
cache-period="31556926" />
<mvc:resources mapping="/bootstrap/**" location="/resource/bootstrap/"
cache-period="31556926" />
<mvc:annotation-driven />
</beans>
页面这样引入css和js:
<link href="<c:url value="/bootstrap/css/bootstrap.min.css" />"
rel="stylesheet">
<script src="<c:url value="/jquery/jquery-1.11.3.min.js" />"></script>
<script src="<c:url value="/bootstrap/js/bootstrap.min.js" />"></script>
0 0
- Spring MVC 使用 静态资源
- Spring : 使用<mvc:resources 访问静态资源
- 【spring mvc(四)】spring mvc使用静态资源
- Spring MVC静态资源处理
- Spring MVC处理静态资源
- spring mvc静态资源处理
- Spring MVC静态资源处理
- Spring MVC静态资源处理
- Spring MVC静态资源处理
- Spring MVC静态资源处理
- Spring MVC静态资源处理
- Spring MVC静态资源处理
- Spring MVC静态资源处理
- Spring MVC静态资源处理
- Spring MVC请求静态资源
- spring mvc 引入静态资源
- Spring MVC静态资源处理
- Spring MVC静态资源处理
- java常用的插件地址
- Lucene全文检索技术
- 更高效的Matlab:适合长时间码代码的配色与Monaco_雅黑字体
- M.2扫盲篇之M.2连接器
- leecode 解题总结:63. Unique Paths II
- Spring MVC 使用 静态资源
- request.getRequestDispatcher().forward(request,response)和response.sendRedirect()的区别
- asp.net core mvc权限控制:在视图中控制操作权限
- hdu1034(模拟题)
- 1041. Be Unique 解析
- 宝钗
- 2017-2-10-w3cschool编程挑战 -javascript
- 快速排序的实现
- hibernate中两表一对一关系 和 session.save()方法和 session.saveOrUpdate()方法