标签:eth src www. utf-8 xmlns 博文 stl end schema
礼悟:
好好学习多思考,尊师重道存感恩。叶见寻根三二一,江河湖海同一体。
虚怀若谷良心主,愿行无悔给最苦。读书锻炼强身心,诚劝且行且珍惜。
javaEE:7
javaSE:1.8
JSTL:1.2.2
server:tomcat 8.5
explorer:Chrome
os:windows7 x64
ide:MyEclipse 2017
工程目录结构
web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> <servlet> <servlet-name>MyServlet</servlet-name> <servlet-class>jizuiku.web.servlet.MyServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>MyServlet</servlet-name> <url-pattern>/MyServlet</url-pattern> </servlet-mapping> </web-app>
Servlet类代码
package jizuiku.web.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * HttpServletRequest getXXXX * * @author 给最苦 * @version V17.10.25 */ public class MyServlet extends HttpServlet { /** * */ private static final long serialVersionUID = 1L; @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String queryString = request.getQueryString(); String requestURI = request.getRequestURI(); // request.getRequestURL()返回的是StringBuffer String requestURL = request.getRequestURL().toString(); // 全路径 什么都有的那种 String fullPath = requestURL + "?" + queryString; System.out.println("参数部分:" + queryString); System.out.println("请求uri:" + requestURI); System.out.println("请求url:" + requestURL); System.out.println("全路径:" + fullPath); } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub } }
浏览器进行查看
控制台输出效果
学习资源:itcast和itheima视频库。如果您有公开的资源,可以分享给我的话,用您的资源学习也可以。
博文是观看视频后,融入思考写成的。博文好,是老师讲得好。博文坏,是 给最苦 没认真。
HttpServletRequest getXXX 获取参数、请求uri url、全路径
标签:eth src www. utf-8 xmlns 博文 stl end schema
原文地址:http://www.cnblogs.com/jizuiku/p/7744115.html