在spring配置文件中写入以下web
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/" p:suffix=".jsp" />spring
InternalResourceViewResolver :将解析controller层返回的视图名称app
p:prefix 指定前缀jsp
p:suffix 指定后缀blog
例如在controller层方法中:servlet
@RequestMapping("/text")
public String textOne(String contactid) {
String xx = "hello";
return xx;
}it
这将会返回/hello.jspclass
若不想被解析,能够在方法上加上@ResponseBody配置
例如:方法
@RequestMapping("/text")
@ResponseBody
public String textOne(String contactid) {
String xx = "hello";
return xx;
}
这就返回:hello
想了解具体SpringMVC视图解析器,能够看看这个http://haohaoxuexi.iteye.com/blog/1770554