更改URL时页面丢失Spring MVC中的资源

时间:2015-07-14 08:40:14

标签: java spring spring-mvc

我使用Spring MVC制作了一个webview(我对Spring来说很新),大部分都没问题,但当我将页面网址从mydomain.com/admin/更改为{{1}时我的资源映射崩溃了。我希望Spring会理解这两种形式的URL,但我错了。

这里是所有实验部分的调度员servlet资源映射

mydomain.com/admin

视图本身

<mvc:resources mapping="/admin/**" location="/resources/theme/"/>
    <mvc:resources mapping="/admin**" location="/resources/theme/"/>
    <mvc:resources mapping="**/dist/**" location="/resources/theme/dist/"/>
    <mvc:resources mapping="**/bootstrap/**" location="/resources/theme/bootstrap/"/>
    <mvc:resources mapping="**/plugins/**" location="/resources/theme/plugins/"/>
<mvc:annotation-driven />

部分

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<jsp:include page="partials/head.jsp"/>
<body class="skin-blue sidebar-mini">
<div class="wrapper">

  <jsp:include page="partials/header.jsp"/>
  <jsp:include page="partials/leftmenu.jsp"/>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">

    <!-- Content itself goes here -->


  </div><!-- /.content-wrapper -->

  <jsp:include page="partials/footer.jsp"/>
  <jsp:include page="partials/csidebar.jsp"/>

</div><!-- ./wrapper -->

<jsp:include page="partials/scripts.jsp"/>

</body>
</html>

我做错了什么?

1 个答案:

答案 0 :(得分:0)

刚刚解决了麻烦。 我用了

<mvc:resources mapping="/dist/**" location="/resources/theme/dist/"/>
<mvc:resources mapping="/bootstrap/**" location="/resources/theme/bootstrap/"/>
<mvc:resources mapping="/plugins/**" location="/resources/theme/plugins/"/>
<mvc:annotation-driven />

而不是

<mvc:resources mapping="/admin/**" location="/resources/theme/"/>
<mvc:resources mapping="/admin**" location="/resources/theme/"/>
<mvc:resources mapping="**/dist/**" location="/resources/theme/dist/"/>
<mvc:resources mapping="**/bootstrap/**" location="/resources/theme/bootstrap/"/>
<mvc:resources mapping="**/plugins/**" location="/resources/theme/plugins/"/>
<mvc:annotation-driven />

错误是操作页面相关的URL。当我试图从一切正常的地方捕获对我的资源文件夹的请求时

相关问题