【发布时间】:2015-09-16 18:15:38
【问题描述】:
我有一个基本的 spring MVC 项目(他们创建的基本模具),并试图让它运行 html 而不是 JSP(JSP 工作完美)
我的控制器
@Controller
@RequestMapping("/")
public class HelloController {
@RequestMapping(method = RequestMethod.GET)
public String printWelcome(ModelMap model) {
model.addAttribute("message", "Hello world!");
return "index";
}
}
我的 mvc 调度服务
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<context:component-scan base-package="com.springapp.mvc"/>
<!--<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">-->
<!--<property name="prefix" value="/WEB-INF/pages/"/>-->
<!--<property name="suffix" value=""/>-->
<!--</bean>-->
<mvc:resources mapping="/WEB-INF/pages/" location="/WEB-INF/pages/" />
我尝试了很多事情,例如映射到 /WEB-INF/pages/** ,完全删除 InternalResourceViewResolver(W/ 以前的映射),将后缀留空,使用 html 等,但无济于事。我看过与此类似的其他问题,但没有运气。还阅读了关于 htmls 的静态文件夹,但很困惑......我做错了什么?
网页的文件结构 网络应用
--WEB-INF ----页数 ------hello.jsp, index.html
【问题讨论】:
标签: java html spring spring-mvc intellij-idea