我正在使用 Spring 2.5.6 和 MVC。我正在开发的新网站有静态页面,例如主页、简单登陆页面等,以及其他 CRUD 类型的页面。
我花了很长时间让两者一起工作,所以显然我做了一些非常错误的事情,因为它不会那么难。
首先我以以下示例开始:
<bean name="/account-landing.html" class="com.account.web.AccountLandingController">
<property name="commandClass" value="com.account.web.AccountLandingCommand"/>
<property name="formView" value="account-landing"/>
<property name="successView" value="account-landing"/>
</bean>
还有其他几个,效果很好。
现在我想介绍一下静态页面
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mapping">
<props>
<prop key="/home.html">urlFilenameViewController</prop>
[snip]
</props>
</property>
</bean>
<bean id="urlFilenameViewController" class="org.springframework.web.servlet.mvc.UrlFilenameViewController"/>
并且有一个 View 解析器。我的应用程序中的所有页面都已转换为 .jsp。
我已经查看了文档,但仍然没有点击。
谢谢
最佳答案
如果你想要静态页面,就不要映射。将其放在单独的文件夹中并访问它。毕竟这是一个网络应用程序
喜欢http://<ip>/appname/htmls/test.html
关于java - Spring MVC如何显示静态页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5785847/