在jsp转发之后,无法找到静态资源

时间:2016-08-28 09:34:38

标签: java jsp

我遇到一个问题,当我在<jsp:forward>中使用index.jsp标记转发到main.jsp等其他网页时,我无法再找到我的静态资源了。但是当我直接浏览main.jsp时,没有任何问题。

  

这是我的main.jsp

的头标记
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width, maximum-scale=1.0, initial-scale=1.0, user-scalable=0"/>
    <meta content="yes" name="apple-mobile-web-app-capable"/>
    <meta content="black" name="apple-mobile-web-app-status-bar-style"/>
    <meta content="telephone=no" name="format-detection"/>
    <meta content="email=no" name="format-detection"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <link rel="stylesheet" type="text/css" href="../styles/swiper.min.css">
    <link rel="stylesheet" type="text/css" href="../styles/index.css"/>
    <script type="text/javascript" src="../scripts/jquery.js"></script>
    <script type="text/javascript" src="../scripts/picBox.js"></script>
    <script type="text/javascript" src="../scripts/swiper.jquery.js"></script>
    <script type="text/javascript" src="../scripts/pagination.js"></script>
</head>
<body>
  

这是我的index.jsp

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">

    <title>My JSP 'index.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
</head>
<body>
<jsp:forward page='/WEB-INF/pages/main/main.jsp'/>
</body>
</html>

this is the structure of webapp

1 个答案:

答案 0 :(得分:-1)

将您的页面文件夹从WEB-INF移动到webapp然后它将起作用。