【问题标题】:css is not running while running requestDispatcher运行 requestDispatcher 时 css 未运行
【发布时间】:2015-07-01 13:55:15
【问题描述】:

我有一个个人资料页面,其中包含一个母版页welcome.jsp。当我转到个人资料页面时,欢迎页面模板的 CSS 运行良好,但当我更新用户时,用户已正确更新,requestDispatcher 运行良好,但welcome.jsp 的 CSS 运行不正常

代码:profile.jsp

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Profile Page</title>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//malsup.github.com/jquery.form.js"></script>
  <script>
     <jquery code>
  </script>  
</head>
<body>
    <%@ include file="welcome.jsp"%>

<center><h1>User Profile</h1></center><br><br>

<form action="/devilmaycry/register?action=updateuser" method="post">
   <html code>
</form>

</body>
</html>

  `request dispatcher code`

          rd=req.getRequestDispatcher("/Register/profile.jsp");  
          rd.include(req, res);
          pw.println("<h3>Record Updated !!!<h3>");

谁能告诉我为什么 CSS 会被禁用

由于声誉低,无法发布图片:(

【问题讨论】:

  • 这可能是包含在包含中的 css 文件的路径问题。仔细检查你的路径。
  • 是的,我在一分钟前发现了这个问题并自己回答了问题

标签: html css jsp requestdispatcher


【解决方案1】:

我给 CSS 文件的路径是 relative ,所以当 requestDispatcher 运行时它改变了目录,所以相对路径不起作用

分辨率 --> 总是尝试给absolute 外部文件的路径( .css , .jsp 等)

【讨论】:

    猜你喜欢
    • 2015-05-15
    • 2016-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-22
    • 1970-01-01
    相关资源
    最近更新 更多