spring3 mvc支持rest,丰富的注解,应用起来非常方便,对所有的请求当做rest来处理,这就会带来一个问题,
如果是静态资源,如js、css和图片,就会导致无法完成请求。
我们可以通过Spring3.0的新注解解决这个问题
<mvc:resources location="/resources/" mapping="/resources/**"/>
2、web.xml文件内容
3、rest-servlet.xml文件内容
4、controller的内容
5、页面的内容(部分内容)
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="authz" uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet"
href="<c:url value="/resources/css/login.css"/>" />
<script type="text/javascript" src="<c:url value="/resources/js/jquery-1.6.js"/>"></script>
<script type="text/javascript" src="<c:url value="/resources/js/Login.js"/>"></script>
</head>
<body>
<authz:authorize ifNotGranted="ROLE_USER,ROLE_ADMIN,ROLE_VIP">
<form action="<c:url value="/login.do"/>" method="post" id="loginForm">
<table cellspacing="0" cellpadding="0" width="783" align="center"
border="0">
<tbody>
<tr>
<td colspan="3"><img src="<c:url value="/resources/images/login/login_head.jpg"/>"
width="783" height="254" /></td>
</tr>
<tr>
<td width="282"><img src="<c:url value="/resources/images/login/login_left.jpg"/>"
width="282" height="156" /></td>
这样就可以访问static的资源了。。。。。。。。