java Spring 3 MVC - 没有控制器的 JSP 页面的查看解析器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9970035/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Spring 3 MVC - View Resolver for JSP pages with no controller
提问by coldholic
I just started the spring 3 development and I had use spring 2.5 previously. I got stuck with the View Resolver. I had the following configuration
我刚刚开始 spring 3 开发,我以前使用过 spring 2.5。我被视图解析器卡住了。我有以下配置
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
And yes it works if the jsp pages is in the /WEB-INF/jsp path. The problem that I stumble is that if I had a jsp inside (e.g. /WEB-INF/jsp/prod/Monitor/success.jsp), I cannot get it to resolve the page if I type http://localhost/Project/prod/Monitor/success.htmlin the browser.
是的,如果 jsp 页面位于 /WEB-INF/jsp 路径中,它就可以工作。我偶然发现的问题是,如果我在里面有一个 jsp(例如 /WEB-INF/jsp/prod/Monitor/success.jsp),如果我输入http://localhost/Project/,我将无法解析页面prod/Monitor/success.html在浏览器中。
Did i miss anything here. Just for more info, the jsp will show up if the jsp had a controller, but I need it to resolve jsp pages with no controller associate with it.
我错过了什么吗?只是为了更多信息,如果jsp有控制器,jsp就会显示出来,但我需要它来解析没有控制器关联的jsp页面。
回答by vacuum
Add this into context:
将此添加到上下文中:
<mvc:view-controller path="/prod/Monitor/success.html" view-name="/prod/Monitor/success" />