SpringMVC配置
2021-05-29 07:02
标签:world ring mys path handler enc resolve set request SpringMVC配置 标签:world ring mys path handler enc resolve set request 原文地址:https://www.cnblogs.com/lgx123/p/14771758.htmlSpringMVC配置
web.xml
springmvc-servlet.xml
controller
package com.luoshen.controller;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
public class RestController implements Controller {
public ModelAndView handleRequest(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse) throws Exception {
ModelAndView mv=new ModelAndView();
String result="hello world";
mv.addObject("result",result);
mv.setViewName("home");
return mv;
}
}
//注解方式
package com.luoshen.controller;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
@Controller
public class RestController {
@RequeMapping("/hello")
public String hello(){
return "home";
}
}
pom.xml
上一篇:c++ explicit 关键字
下一篇:SpringMVC配置