request.getRequestURI()与request.getRequestURL()区别

(1) request.getRequestURI()与request.getRequestURL()


request.getRequestURI()只是显示的是文件的名称
request.getRequestURL()显示的全部的URL

 

可以System.out.printle(); 打印结果试试看,比较两者的区别。

 

(2)Request.getRequestURI()

Syntax

Request.getRequestURI()

Returns

The URL string corresponding to the current client request.

Description

The string returned does not include the server name or query arguments. If the client's browser was directed at http://webname.dataweb.com/test/expression.csp, the getRequestURI() method would return /test/expression.csp.

Example

   response.write("URI: " + Request.getRequestURI());
   // prints: "URI: /ObjectCode/sampcode_request.ws"
   // where "ObjectCode" is a folder in a web

你可能感兴趣的:(Web)