1

純粋なhtmlページを使用してSpring MVCアプリを構築するにはどうすればよいですか? Tomcat 7 サーバーに jsps をデプロイすると、ページを適切にマップできます。ただし、html の場合、ページは表示されません。404 エラーが発生します。spring mvcでjspsを使用しないようにするにはどうすればよいですか? 必要な手順を詳しく説明してください。

前もって感謝します。

4

3 に答える 3

1

Spring MVC では、すべてのリクエストは FrontController - DispatcherServlet を通過します。

そこで、Spring に jsp と html の両方を許可するように指示する必要があります。

dispatcher-servlet.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:p="http://www.springframework.org/schema/p"
   xmlns:aop="http://www.springframework.org/schema/aop"
   xmlns:tx="http://www.springframework.org/schema/tx"
   xsi:schemaLocation="http://www.springframework.org/schema/beans           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

    <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>

    <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="mappings">
            <props>
                <prop key="index.htm">indexController</prop>
            </props>
        </property>
    </bean>

    <bean id="viewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver"
          p:prefix="/WEB-INF/jsp/"
          p:suffix=".jsp" />

    <bean name="indexController"
          class="org.springframework.web.servlet.mvc.ParameterizableViewController"
          p:viewName="index" />
    <bean name="/*.htm" class="controller.MyController"/>
</beans>
于 2013-10-04T06:39:58.707 に答える