首先,您需要清楚的是,当您使用MVC时,您可以以任何您想要的方式提供页面。这是您的问题的一个可能的解决方案,这是我自己的应用程序的实际代码。
您可能想要像这样提供* .html请求。
的web.xml
appServlet
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
PATH/TO/YOUR/SERVLET-CONTEXT.xml
1
appServlet
*.html
然后在你的servlet-context.xml中,您可以配置VelocityViewResolver这样。
然后从你的控制器,返回要呈现的视图的名称,这不应该包括扩展。
return "template"; //Return the name of view to be found in the views folder.
//The template.vm should be present in your views folder.
这会解决您的问题。
请清楚,在MVC中,视图根据您的要求的类型返回,文件类型的没有实际发生转换。