使用spring mvc设置默认的jsp视图 [英] Setting the default jsp view with spring mvc
问题描述
我想在jsps文件夹中设置一个jsp文件作为应用程序的默认视图。我们有什么方法可以告诉< welcome-file-list>
abc.jsp
需要默认它可以在这样的道路上找到。 url模式也是html,所以有一种方法可以在Spring MVC中映射。
I want to set one of jsp files in my jsps folder as the default view for the application. Is there any way we can tell in <welcome-file-list>
that abc.jsp
needs to be default and it can be found in such and such path. Also the url pattern is html so is there a way it can be mapped in Spring MVC.
例如 - 当用户键入 www.example时.com
,我希望应用程序指向 abc.jsp
页面,当有人输入 www.example.com时/ something
,即使那时应用程序应该直接指向 abc.jsp
,但是url模式不应该被破坏。
For example - When a user types www.example.com
, I want the application to direct to abc.jsp
page and also when someone types www.example.com/something
, even then application should direct to abc.jsp
, but the url pattern shouldnt be compromised.
推荐答案
添加
<mvc:view-controller path="/" view-name="abc"/>
到配置文件。然后ROOT将解析为abc视图。然后添加
to the config file. Then the ROOT will resolve to the abc view. Then add
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>
到配置文件。这会将视图解析为/WEB-INF/view/abc.jsp。
to the config file. This will resolve the view to /WEB-INF/view/abc.jsp.
这篇关于使用spring mvc设置默认的jsp视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!