SpringMVC简单配置
创始人
2024-06-01 05:15:42

1、pom.xml配置

org.springframeworkspring-webmvc5.1.12.RELEASEorg.apache.maven.pluginsmaven-compiler-plugin3.21.81.8UTF-8-parametersorg.apache.tomcat.maventomcat7-maven-plugin2.280/

2、web.xml

DispatcherServletorg.springframework.web.servlet.DispatcherServletcontextConfigLocationclasspath:springmvc.xml1DispatcherServlet/

3、springmvc.xml

4、处理类

@Controller
@RequestMapping("/demo")
public class TestController {@RequestMapping("/handler")public ModelAndView test(){Date date = new Date();ModelAndView modelAndView = new ModelAndView();modelAndView.addObject("date",date);modelAndView.setViewName("success");System.out.println("---------" + modelAndView.getClass());return modelAndView;}@RequestMapping("/handler1")public String handler1(Map map){Date date = new Date();map.put("date",date);System.out.println("---------" + map.getClass());return "success";}/*** class org.springframework.validation.support.BindingAwareModelMap*/@RequestMapping("/handler2")public String handler1(ModelMap map){Date date = new Date();map.put("date",date);System.out.println("---------" + map.getClass());return "success";}@RequestMapping("/query")public String query(User user){System.out.println("-----name-------" + user.getName());System.out.println("______id________" + user.getAge());Date date = new Date();ModelMap map = new ModelMap();map.put("date",date);return "success";}
}

相关内容

热门资讯

苗族的传统节日 贵州苗族节日有... 【岜沙苗族芦笙节】岜沙,苗语叫“分送”,距从江县城7.5公里,是世界上最崇拜树木并以树为神的枪手部落...
北京的名胜古迹 北京最著名的景... 北京从元代开始,逐渐走上帝国首都的道路,先是成为大辽朝五大首都之一的南京城,随着金灭辽,金代从海陵王...
阿西吧是什么意思 阿西吧相当于... 即使你没有受到过任何外语培训,你也懂四国语言。汉语:你好英语:Shit韩语:阿西吧(아,씨발! )日...
长白山自助游攻略 吉林长白山游... 昨天介绍了西坡的景点详细请看链接:一个人的旅行,据说能看到长白山天池全凭运气,您的运气如何?今日介绍...