Java 使用SpringMVC的纯HTML页面应用程序
如何使用纯html页面构建SpringMVC应用程序?当我在Tomcat7服务器上部署JSP时,它能够很好地映射页面。但是对于html,页面不会显示。我得到404个错误。我怎么能不在SpringMVC中使用JSP呢?请详细说明我需要采取的步骤Java 使用SpringMVC的纯HTML页面应用程序,java,spring,tomcat,spring-mvc,tomcat7,Java,Spring,Tomcat,Spring Mvc,Tomcat7,如何使用纯html页面构建SpringMVC应用程序?当我在Tomcat7服务器上部署JSP时,它能够很好地映射页面。但是对于html,页面不会显示。我得到404个错误。我怎么能不在SpringMVC中使用JSP呢?请详细说明我需要采取的步骤 提前谢谢你。百里埃拉夫将是你的朋友 在Spring MVC中,所有请求都通过FrontController-DispatcherServlet进行 在这里,您需要告诉Spring在您的案例中允许jsp和html 示例 dispatcher-servlet.
提前谢谢你。百里埃拉夫将是你的朋友
在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>
dispatcher-servlet.xml:
索引控制器
请将视图解析程序后缀更改为.html,以便viewResolver能够呈现您的视图。答案中有一些建议,我不明白这个参数化ViewController是关于什么的。还有,bean名称“/*.htm”
的处理方法是什么?你能详细说明你的答案吗?我对春天很陌生。请给我解释一下你提供的xml是怎么回事我希望能得到解释。你能给我一些建议吗?