1、创建一个maven webapp工程先,不知道咋创建的,看链接
Idea配置Maven详细教程
Idea中如何创建maven项目
这都给你讲的明明白白的,我写的必然明白啊~
2、修改web.xml文件,如下
Archetype Created Web Application dispatcher org.springframework.web.servlet.DispatcherServlet 1 dispatcher / encodingFilter org.springframework.web.filter.CharacterEncodingFilter encoding UTF-8 forceEncoding true encodingFilter @Controller public class MyController { @RequestMapping("login") //用来处理前台的login请求 private @ResponseBody String hello( @RequestParam(value = "username", required = false)String username, @RequestParam(value = "password", required = false)String password ){ return "Hello "+username+",Your password is: "+password; } }
7、最后部署工程,运行
妙啊~



