开发者

Spring 3 MVC : same URL for the whole site

I'm trying to make it so that users will see the same static URL although page they are on will change.

For example, I want the user to always see:

www.mysite.com

Even if i redirect them to

  • www.mysite.com/1.html
  • www.mysite.com/2.html
  • www.mysite.com/2.jsp

etc...

I have Spring MVC, and that hides the JSP, but I want a "static hide URL". Can anybody tell me how开发者_如何学Go to achieve it?


Map the Controller to "/" and set up ViewResolvers to handle each view. The controller then needs to direct the request to the appropriate view, by returinign different view names.

Note, that without offering alternative URLs you will need to resort to Cookies, POST requests or other logic to determine which page / view to render, which makes life a little harder.

Think seriously about whether you really want one URL at the HTTP request level. If all you want is to make the browser address bar stay the same them Frames or AJAX may be an easier way forward, behind the scenes these allow for different URLs to be used without changing the address at the top of the browser window.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜