<mvc:resources mapping =“/ resources / **”location =“/ resources /”> </mvc:resources>

时间:2015-03-09 05:54:16

标签: spring model-view-controller

这是dispatcher-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc 
                        http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
                        http://www.springframework.org/schema/beans 
                        http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
                        http://www.springframework.org/schema/context 
                        http://www.springframework.org/schema/context/spring-context-3.2.xsd
                        http://www.springframework.org/schema/aop 
                        http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
                        http://www.springframework.org/schema/tx 
                        http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">

<mvc:annotation-driven />

<context:component-scan base-package="com.web.controllers" />

<mvc:resources mapping="/resources/**" location="/resources/" />
<!--  <mvc:default-servlet-handler />  -->

  <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
     <beans:property name="prefix" value="/WEB-INF/views/" />
     <beans:property name="suffix" value=".jsp" />
   </beans:bean>    

</beans:beans>

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <%@ taglib prefix="core" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

    <!DOCTYPE html>
    <html>
    <head>
    	<title>mypage</title>
    		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
    		<meta charset="utf-8">
    		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    		<link href="${pageContext.request.contextPath}/WebContent/resources/mycustom/fabrication.css" rel="stylesheet">
    		<link href="${pageContext.request.contextPath}/WebContent/resources/mycustom/boxmodel.css" rel="stylesheet">
    	 <link href="<c:url value="/resources/css/bootstrap.min.css" />" rel="stylesheet">
    	 <link href="${pageContext.request.contextPath}/WebContent/resources/css/moslake_style.css" rel="stylesheet">
        <link href="${pageContext.request.contextPath}/WebContent/resources/css/boxmodel.css" rel="stylesheet">
        <link href="${pageContext.request.contextPath}/WebContent/resources/css/font.css" rel="stylesheet">
        <link href="${pageContext.request.contextPath}/WebContent/resources/css/media.css" rel="stylesheet">
        <script src="<c:url value="/resources/js/jquery.min.js" />"></script>
        <script src="<c:url value="/resources/js/bootstrap.min.js" />"></script>
    </head>

    <body bgcolor="#F5FAFA">
    <h1>${pageContext.request.contextPath}</h1>
    <div class="header">
    <div class="navbar navbar-default navbar-fixed-top">
    	<div class="container-fluid">
    	
        	<div class="row">
        		<div class="col-md-5"></div><!--end of first row columns-->
        		<div class="col-md-2">
        			<a class="navbar-brand" href="#"><img src="img/swing.png" alt="swing logo" height="50" width="100"></a>
        		</div>
        		<div class="col-md-5"></div>
        	</div><!--end of row-->
        	
        	<div class="row">
          			<div class="col-md-5">
          				<ul class="nav nav-pills">
          					<li>
          						<button  class="dropdown-toggle btn-primary btn-sm" data-toggle="dropdown"  type="button">
          							<span class="glyphicon glyphicon-menu-hamburger"></span>
    	      					</button>
    	      					<ul class="dropdown-menu">
    	      						<li><p align="center">Projects List</p></li>
    									<li class="divider"></li>
    									<li><a href="#"><b>Project1</b></a></li>
    									<li><a href="#"><b>Project2</b></a></li>
    									<li><a href="#"><b>Project3</b></a></li>
    									<li><a href="#"><b>Project4</b></a></li>
    									<li><a href="#"><b>Project5</b></a></li>
    	      					</ul>
          					</li>
          					<li  class="dropdown">
          						<button type="button" class="dropdown-toggle btn-primary btn-sm" data-toggle="dropdown">
        								<span class="glyphicon glyphicon-plus"></span>
    								</button>
    								<ul class="dropdown-menu">
    									<li><p align="center">Add</p></li>
    									<li class="divider"></li>
    									<li><a href="#"><b>New Project</b></a></li>
    								</ul>
          					</li>
          					<li>
          						<form class="navbar-search" id="srch" action="#">
    		  							<input type="text" class="form-control" placeholder="Search">
          					</li>
          					<li>
          						<button class="btn btn-primary btn-md" type="submit"><span class="glyphicon glyphicon-search"></span>Search</button>
    								</form>
          					</li>
          				</ul>	
          			</div><!--end of col-md-5-->
          			          	
              	<div class="col-md-4"></div><!--end of col-md-4-->
              	
              	<div class="col-md-3">
              		<ul class="nav nav-pills">
              			<li>
              				<a class="btn btn-basic">hello!
              					<span class="badge">Abbas Kapasi</span>
              				</a>
              			</li>
              			<li  class="dropdown">
              				<button class="dropdown-toggle btn-primary btn-sm" data-toggle="dropdown"><i class="glyphicon glyphicon-user"></i> <i class="glyphicon glyphicon-chevron-down"></i></button>
              				<ul class="dropdown-menu">
    				  				<li><a href="#">Profile</a></li>
    				  				<li class="divider"></li>
    				  				<li><a href="#">Logout</a></li>	
    				 			</ul>
              			</li>
              		</ul>
              	</div><!--end of col-md-3-->
              
          </div><!--end of nested row-->
        </div><!--end of main container-->    	
    </div><!--end of nav-->
    </div><!--end of header-->
    </body>
    </html>

这会导致以下错误:

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <%@ taglib prefix="core" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

    <!DOCTYPE html>
    <html>
    <head>
    	<title>mypage</title>
    		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
    		<meta charset="utf-8">
    		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    		<link href="${pageContext.request.contextPath}/WebContent/resources/mycustom/fabrication.css" rel="stylesheet">
    		<link href="${pageContext.request.contextPath}/WebContent/resources/mycustom/boxmodel.css" rel="stylesheet">
    	 <link href="<c:url value="/resources/css/bootstrap.min.css" />" rel="stylesheet">
    	 <link href="${pageContext.request.contextPath}/WebContent/resources/css/moslake_style.css" rel="stylesheet">
        <link href="${pageContext.request.contextPath}/WebContent/resources/css/boxmodel.css" rel="stylesheet">
        <link href="${pageContext.request.contextPath}/WebContent/resources/css/font.css" rel="stylesheet">
        <link href="${pageContext.request.contextPath}/WebContent/resources/css/media.css" rel="stylesheet">
        <script src="<c:url value="/resources/js/jquery.min.js" />"></script>
        <script src="<c:url value="/resources/js/bootstrap.min.js" />"></script>
    </head>

    <body bgcolor="#F5FAFA">
    <h1>${pageContext.request.contextPath}</h1>
    <div class="header">
    <div class="navbar navbar-default navbar-fixed-top">
    	<div class="container-fluid">
    	
        	<div class="row">
        		<div class="col-md-5"></div><!--end of first row columns-->
        		<div class="col-md-2">
        			<a class="navbar-brand" href="#"><img src="img/swing.png" alt="swing logo" height="50" width="100"></a>
        		</div>
        		<div class="col-md-5"></div>
        	</div><!--end of row-->
        	
        	<div class="row">
          			<div class="col-md-5">
          				<ul class="nav nav-pills">
          					<li>
          						<button  class="dropdown-toggle btn-primary btn-sm" data-toggle="dropdown"  type="button">
          							<span class="glyphicon glyphicon-menu-hamburger"></span>
    	      					</button>
    	      					<ul class="dropdown-menu">
    	      						<li><p align="center">Projects List</p></li>
    									<li class="divider"></li>
    									<li><a href="#"><b>Project1</b></a></li>
    									<li><a href="#"><b>Project2</b></a></li>
    									<li><a href="#"><b>Project3</b></a></li>
    									<li><a href="#"><b>Project4</b></a></li>
    									<li><a href="#"><b>Project5</b></a></li>
    	      					</ul>
          					</li>
          					<li  class="dropdown">
          						<button type="button" class="dropdown-toggle btn-primary btn-sm" data-toggle="dropdown">
        								<span class="glyphicon glyphicon-plus"></span>
    								</button>
    								<ul class="dropdown-menu">
    									<li><p align="center">Add</p></li>
    									<li class="divider"></li>
    									<li><a href="#"><b>New Project</b></a></li>
    								</ul>
          					</li>
          					<li>
          						<form class="navbar-search" id="srch" action="#">
    		  							<input type="text" class="form-control" placeholder="Search">
          					</li>
          					<li>
          						<button class="btn btn-primary btn-md" type="submit"><span class="glyphicon glyphicon-search"></span>Search</button>
    								</form>
          					</li>
          				</ul>	
          			</div><!--end of col-md-5-->
          			          	
              	<div class="col-md-4"></div><!--end of col-md-4-->
              	
              	<div class="col-md-3">
              		<ul class="nav nav-pills">
              			<li>
              				<a class="btn btn-basic">hello!
              					<span class="badge">Abbas Kapasi</span>
              				</a>
              			</li>
              			<li  class="dropdown">
              				<button class="dropdown-toggle btn-primary btn-sm" data-toggle="dropdown"><i class="glyphicon glyphicon-user"></i> <i class="glyphicon glyphicon-chevron-down"></i></button>
              				<ul class="dropdown-menu">
    				  				<li><a href="#">Profile</a></li>
    				  				<li class="divider"></li>
    				  				<li><a href="#">Logout</a></li>	
    				 			</ul>
              			</li>
              		</ul>
              	</div><!--end of col-md-3-->
              
          </div><!--end of nested row-->
        </div><!--end of main container-->    	
    </div><!--end of nav-->
    </div><!--end of header-->
    </body>
    </html>

0 个答案:

没有答案