本文主要是介绍JSPSERVLET学习笔记(三):URL模式设置,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
//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();
}
}
这篇关于JSPSERVLET学习笔记(三):URL模式设置的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!