Spring MVC如何显示静态页面

时间:2011-04-26 04:12:42

标签: java spring-mvc

我正在使用带有MVC的spring 2.5.6。我正在处理的新网站有静态页面,例如主页,简单的目标网页等,以及其他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"/>

并且有一个视图解析器。我的应用程序中的所有页面都已转换为.jsp。

我查看了文档,但仍未点击。

由于

1 个答案:

答案 0 :(得分:1)

如果您希望静态页面不映射。把它放在一个单独的文件夹中并访问它。毕竟这是一个网络应用程序

喜欢http://<ip>/appname/htmls/test.html