监听器过滤器,实体

master
xiaolei 6 years ago
parent 9723c89d41
commit c78ccf9352

@ -0,0 +1,52 @@
package com.ssm.controller.user;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.ssm.bean.User;
import com.ssm.service.UserService;
/**
*
* @author Nocol
*
*/
@Controller
@RequestMapping("/user")
public class UserAction {
//注入Service
@Autowired
private UserService userService;
@RequestMapping("regist")
public String regist(User user,Model model){
System.out.println("用户注册:"+user.getName()+user.getPassword());
user.setId(1);
userService.regist(user);
model.addAttribute("msg", "注册成功");
//注册成功后跳转success.jsp页面
return "success";
}
@RequestMapping("login")
public String login(String name,String password,Model model){
System.out.println("用户登录:"+name+password);
/*Map<String, String> map=new LinkedHashMap<String,String>();
map.put("name", user.getName());
map.put("password", user.getPassword());*/
userService.login(name,password);
model.addAttribute("msg", "登录成功");
return "success";
}
}

@ -0,0 +1,43 @@
<!-- spring /WEB-INF/applicationContext.xml -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- contextConfigLocationSpring -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext*.xml</param-value>
</context-param>
<!-- Spring MVC -->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/springmvc-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Spring MVC -->
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- -->
<filter>
<filter-name>characterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
Loading…
Cancel
Save