javaweb 转发 request.getRequestDispatcher 会导致页面的引入外部 财富值88

2016-10-23 07:39发布

我的一个页面 在doGet里面 转发给本身.
结果css 的样式全部消失了,body的背景图片也没有了

然后我就把css属性直接写在html文件里面 没用用外部文件引入了

但是img文件 不能这样做 还是要导入,只要转发了 就不行,背景图片会消失.

用sendRedirect方法的话可以正常

而且还有个问题想问下:
不是说转发的话地址栏里的地址是不会变的吗?
为什么我的地址栏里的地址变了?

import java.io.IOException;  import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;  public class Login extends HttpServlet {      public void doPost(HttpServletRequest request, HttpServletResponse response)             throws ServletException, IOException {         System.out.println("Login : registe doGet");         //分别获得username 和 password 用字符串来接受         String username = request.getParameter("username");         String password = request.getParameter("password");         try {             boolean loginBoolean = JDBC.loginSelect(username, password);             if (loginBoolean) {                 System.out.println("Login : register :success");                 //点击登录 ,验证mysql成功后 转发到from01 页面                 request.getRequestDispatcher("/form01.html").forward(request, response);                                 }else {                 System.out.println("Login : register : fail");                 //点击登录 ,验证mysql失败 转发原页面         引入的外部文件会消失                 request.getRequestDispatcher("/login1/login.html").forward(request, response);                }         } catch (Exception e) {             e.printStackTrace();         }     }      public void doGet(HttpServletRequest request, HttpServletResponse response)             throws ServletException, IOException {          doPost(request, response);     }    } 
友情提示: 问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
0条回答