springMvc 处理HttpRepsonse时 同时设置response.setStatus(301)
和response.sendRedirect("/hello");
时,HTTP response Headers status is 302
调换两个的位置也是如此,所以想理解下具体的原理
相关代码
//input
response.sendRedirect("/hello");
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
// output
Request URL: http://localhost:9999/account/list
Request Method: GET
Status Code: 302
Remote Address: [::1]:9999
Referrer Policy: no-referrer-when-downgrade
HTTP/1.1 302
Location: http://localhost:9999/hello
Content-Length: 0
Date: Sun, 29 Jul 2018 17:38:31 GMT
没用过springMVC ,估计这个302是sendRedirect 里面发送的吗,去看一下这个函数的源码,就知道了