0

I have a problem that when I use <jsp:forward> tag in my index.jsp to forward to other pages such as main.jsp, I can't find my static resource anymore.But when i browse main.jsp directly,there are no problems.

this is the head tag of my 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>

this is my 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

Aezio
  • 203
  • 5
  • 18
  • can you also post your folder/file structure tree of your web project, (in which folder your static content and your jsp files reside). by the way, you should avoid putting your public pages under WEB-INF folder. – guleryuz Aug 28 '16 at 10:02
  • @guleryuz ok I have posted my structure tree.At the same time I have a question that when i get the static resource by using the relative path like what I have done in the head tag file of the main.jsp,everything is fine.But after using the tag, I cant use the path like this,all paths started with localhost:port/mystaticfloder/resourcrs.My project name has missed.It force me to use the absolute path to solve the problem.Is there any way to use the relative path to solve it ? – Aezio Aug 29 '16 at 01:28

1 Answers1

-1

move your pages folder form WEB-INF to webapp then it will work.

Srinivas Gadilli
  • 342
  • 6
  • 25