版权声明:尊重原创,转载请标明出处 https://blog.csdn.net/jifgjifg/article/details/54981085
- 页面引入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>