1. 程式人生 > >HTTP GET請求URL設定和互動

HTTP GET請求URL設定和互動

GET請求要傳遞的引數都在URL裡,不在請求體中
如有以下URL:

xxxx/login?username=52318&code=8888
格式是:/請求名?引數1=值1&引數2=值2

那麼後臺的URL擷取配置為login請求名即可

註解配置:
@RequestMapper("/login")
或者web.xml配置
<url-pattern>/login</url-pattern>

同時後臺可以這樣獲取引數

String username = httpServletRequest.getParameter
("username"); int code = Integer.parse(httpServletRequest.getParameter("code"));