@ Controller
@ RequestMapping ("/product ")
Public class ProductController {
@ RequestMapping ("/show ")
Public String the showProduct () {
Request. SetAttribute (" pageBean ", pageBean);
The return of "forward:/goodsList. JSP";
}
}
Question:
Forwad:/not forwarded to the root directory, goodsList. JSP in the root directory,
But the browser display path is: http://localhost:8080/shop/product/show? TId=1,
This is not forwarded success?
But the data also has, also at goodsList) shows the JSP, and no CSS and js with other resources, resource structure of browser directory below
So, exactly how to forward success
CodePudding user response:
Forward 1. First of all, is the server, in addition to the content of the response will not have other reactions in the browser, such as address, you said will not change, the redirection is behavior between the browser and server, the browser will exist secondary requests, the browser's address change,2. Page JS, CSS references need to use absolute paths, relative path is easy to appear this kind of problem,
CodePudding user response:
Forwarding will not change the address, will redirectCodePudding user response:
Forwarding is when your browser sends a request to the server, the server itself according to the code you write, will you request of data forwarding to another address, is a request;Is redirect your browser sends a request to the server, the server told browser, again to send the request to another address, is two requests,