如何用springMVC 返回一个指定的HTML页面

如题所述

用springMVC 返回一个指定的HTML页面的方法:
1、在controller层需要做返回指定:
@RequestMapping(value = "/jsptest.html", method = RequestMethod.GET)
public String jspTest(Model model) {
model.addAttribute("account", accountService.getAccount());
return "indextest";
}
2、在资源层放html文件
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".html" />
</bean>
3、对静态资源文件的访问
<mvc:resources location="/img/" mapping="/img/**" />
<mvc:resources location="/js/" mapping="/js/**" />
温馨提示:答案为网友推荐,仅供参考