⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 useraction.java

📁 网上购物系统用SSH实现的
💻 JAVA
字号:
package cn.com.tarena.ecport.web.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.MappingDispatchAction;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import cn.com.tarena.ecport.biz.IUserBusiness;
import cn.com.tarena.ecport.pojo.ContactInfo;
import cn.com.tarena.ecport.pojo.User;
import cn.com.tarena.ecport.web.form.UserForm;

public class UserAction extends MappingDispatchAction {

	public ActionForward toLogin(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		return mapping.findForward("toLogin");
	}
	
	public ActionForward toRegister(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		return mapping.findForward("toRegister");
	}
	
	public ActionForward doRegister(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		ApplicationContext context = new ClassPathXmlApplicationContext("beans_hibernate.xml");
		IUserBusiness userbiz = (IUserBusiness)context.getBean("userBusinessproxy");
		UserForm userForm = (UserForm)form;
		User users = new User();
		ContactInfo contactInfo = new ContactInfo();
		users.setUserName(userForm.getUserid());
		users.setPassword(userForm.getPassword());
		contactInfo.setCellphone(userForm.getCellphone());
		contactInfo.setCity(userForm.getCity());
		contactInfo.setEmail(userForm.getEmail());
		contactInfo.setHomephone(userForm.getHomephone());
		contactInfo.setOfficephone(userForm.getOfficephone());
		contactInfo.setStreet1(userForm.getStreet1());
		contactInfo.setStreet2(userForm.getStreet2());
		contactInfo.setZip(userForm.getZip());
		
		Long id = userbiz.userRegister(users, contactInfo);
		HttpSession session = request.getSession();
		session.setAttribute("userName", id);
		return mapping.findForward("doRegister");
	}
	
	public ActionForward toUserinfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		return mapping.findForward("toUserinfo");
	}
	
	public ActionForward logout(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		return mapping.findForward("logout");
	}
	
	public ActionForward modify(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		return mapping.findForward("userinfo");
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -