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

html-css09

如何用springMVC 返回一个指定的HTML页面,第1张

springMVC指定返回的html页面的方法如下:

在controller中:

@Controller

@RequestMapping("/index.html")

public class MyIndexController {

@RequestMapping(method=RequestMethod.GET)

protected String gotoIndex(Model model) throws Exception {

return "myLandingPage"

}

}

在web.xml中配置如下:

<welcome-file-list>

<welcome-file>index.html</welcome-file>

</welcome-file-list>

其实完全没有必要。

你可以把那几个也做成aspx。

比如你有 test.html,你修改成:test.aspx

在你的控制器里面添加对应的:

ActionResult test()

{

return View()

}

修改你的链接:

<% Html.ActionLink("course", "test") %>

总之你既然用了MVC框架,你就好好用它,与其想怎么样让它和既有写法兼容,不如好好掌握,纯粹用MVC实现。