1.访问资源
运用forward方法只能重定向到同一个Web应用程序中的一个资源。
而sendRedirect方法可以让你重定向到任何URL。
2.request.get
Forward代码中的"/uu"则代表相对与WEB应用的路径。
举例:
Servlet 和 目标文件的包路径:
Servlet 代码:中 doPost 和doGet代码:
request 重定向url地址 或者是是相对于 本项目 (WEB13) http:localhost:8080/WEB13+url ;
url 地址为: /html/Ok.html 或
html/Ok.html
而 response 请求转发 的url 以 ‘ / ‘ 开头 相当于 本服务器 http:localhost:8080+ url url 如: /WEB13/html/No.html
而开头不以 ‘ / ’ 开头 (html/No.html) 就 是 地址想对应本项目 (WEB13) http:localhost:8080/WEB13/+url
1 public voiddoGet(HttpServletRequest request, HttpServletResponse response)2 throwsServletException, IOException {3 request.setCharacterEnco