Spring - Rewrite one URL to another

后端 未结 3 575
花落未央
花落未央 2020-12-09 14:01

I have a Spring 2.5 application that contains a Flash banner. I don\'t have the source for the Flash component but it has links hardcoded to certain pages that end in

3条回答
  •  甜味超标
    2020-12-09 14:02

    Firstly, I'm assuming that when you say "redirect", you really mean "forward". HTTP Redirects would not be appropriate here.

    SO given that, here are some things to try:

    • Can't you just move the JSP files from WebContent into /WEB-INF/jsp/? You wouldn't have to change the ViewResolver definition, then.

    • You could try to have the controllers return a view name of something like ../../another.jsp, and hope that the servlet container resolves to /WEB-INF/jsp/../../another.jsp to /another.jsp.

    • The ViewResolver is only consulted if the controllers return the name of a view. Your controllers don't have to return the name of a view, they can return a View object directly, in this case a JstlView. This can point to whichever JSP you like. You can some controllers returning view names, and some returning View objects.

    • Remove the prefix property from your view resolver. This means you'd also have to change every existing controller, to prefix every view name they return with /WEB-INF/jsp/. Then you could refer to the JSPs under WebContent by name.

提交回复
热议问题