getRequestUI and getRequestURL

getRequestUI()

api

 public String getRequestURI();

    /**
     *
     * Reconstructs the URL the client used to make the request.
     * The returned URL contains a protocol, server name, port
     * number, and server path, but it does not include query
     * string parameters.
<!--重新构造的url用于发出请求,那么这个url则包含server name,port,path但不是不包含查询字符串参数 -->
     *
     * <p>If this request has been forwarded using
     * {@link javax.servlet.RequestDispatcher#forward}, the server path in the
     * reconstructed URL must reflect the path used to obtain the
     * RequestDispatcher, and not the server path specified by the client.
     *
     <!-- **如果这个url被用来转发,那么这个重构的url地址是用RequestDispatcher来映射的,但是它并不是客户端指定的访问地址**-->
     * <p>Because this method returns a <code>StringBuffer</code>,
     * not a string, you can modify the URL easily, for example,
     * to append query parameters.
     *
     * <p>This method is useful for creating redirect messages
     * and for reporting errors.
     *
     <!-- 这个方法对于重定向非常有用-->
     * @return      a <code>StringBuffer</code> object containing
     *          the reconstructed URL
     *
     */
    <!-- 他返回一个重构的url-->

getRequestURL

public StringBuffer getRequestURL();


    /**
     *
     * Returns the part of this request's URL that calls
     * the servlet. This path starts with a "/" character
     * and includes either the servlet name or a path to
     * the servlet, but does not include any extra path
     * information or a query string. Same as the value of
     * the CGI variable SCRIPT_NAME.
<!-- 他返回一个请求URL,是以 / 开头,包括server名字和path-但是不包括额外的路径或者信息,->     

     * <p>This method will return an empty string ("") if the
     * servlet used to process this request was matched using
     * the "/*" pattern.
<!-- 此方法返回一个空字符串,servlet 会以/* 的样式来处理-->
     *
     * @return      a <code>String</code> containing
     *          the name or path of the servlet being
     *          called, as specified in the request URL,
     *          decoded, or an empty string if the servlet
     *          used to process the request is matched
     *          using the "/*" pattern.
     *
     */
<!--这个请求URL将被servlet指定,解码,或者一个空字符串如果servlet匹配成功,就用 /* 的模式 -->

Console

System.out.println("URI:  " +request.getRequestURI());
            System.out.println("URL:   "+ request.getRequestURL().toString());

URI:  /order/order.html
URL:   http://localhost:8092/order.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值