servlet 的一些api

request.getRequestURI()   /jqueryWeb/resources/request.jsp
request.getRequestURL()   http://localhost:8080/jqueryWeb/resources/request.jsp
request.getContextPath()  /jqueryWeb
request.getServletPath()    /resources/request.jsp

注: resources为WebContext下的目录名     jqueryWeb 为工程名

request.getQueryString()

 http://localhost:8080/jqueryWeb/resources/request.jsp?a=123&b=dfdf

得到a=123&b=dfdf

跳转:

getServletContext.getRequsetDispather("/index.html").forword(requset.response);

response.sendRedirect("/index.html");

猜你喜欢

转载自qq510219366.iteye.com/blog/1629170