码迷,mamicode.com
首页 > Web开发 > 详细

JSP&&SERVLET学习笔记(三):URL模式设置

时间:2014-12-23 09:04:35      阅读:247      评论:0      收藏:0      [点我收藏+]

标签:

//URL模式的设置
//                         环境路径          Servlet路径    路径信息
//requestURI = contextPath + servletPath + pathInfo;
//Servlet路径认为/*为空串


package cc.openhome;


import java.io.IOException;
import java.io.PrintWriter;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@WebServlet("/servlet/*")
public class PathServlet extends HttpServlet {
  
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet Pattern</title>");
out.println("</head>");
out.println("<body>");
out.println(request.getRequestURI() + "<br>");
out.println(request.getContextPath() + "<br>");
out.println(request.getServletPath() + "<br>");
out.println(request.getPathInfo());
out.println("</body>");
out.println("</html>");
out.close();
}


}

JSP&&SERVLET学习笔记(三):URL模式设置

标签:

原文地址:http://blog.csdn.net/u012965373/article/details/42098331

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!