- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
UserAction.java
资源名称:Jason.rar [点击查看]
上传用户:wok5188
上传日期:2018-02-20
资源大小:1835k
文件大小:4k
源码类别:
MySQL数据库
开发平台:
Java
- /*
- * Generated by MyEclipse Struts
- * Template path: templates/java/JavaClass.vtl
- */
- package com.center.control;
- import java.io.IOException;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.Map;
- 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.LookupDispatchAction;
- import com.center.commons.DataConnect;
- import com.center.dto.UserDTO;
- import com.center.model.UserManager;
- import com.center.util.DealString;
- import com.center.vo.UserVO;
- import com.mysql.jdbc.Connection;
- /**
- * MyEclipse Struts
- * Creation date: 05-18-2007
- *
- * XDoclet definition:
- * @struts.action path="/user" name="userForm" input="/show/admin/user.jsp" parameter="method" scope="request" validate="true"
- * @struts.action-forward name="ok" path="/ok.jsp"
- * @struts.action-forward name="err" path="/err.jsp"
- */
- public class UserAction extends LookupDispatchAction {
- /*
- * Generated Methods
- */
- /**
- * Method execute
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return ActionForward
- */
- public HttpSession session;
- private Connection conn;
- private UserDTO userdto;
- private UserManager usermanager;
- public ActionForward regist(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) throws SQLException, IOException {
- UserForm UserForm = (UserForm) form;// TODO Auto-generated method stub
- System.out.println("hell");
- conn = (Connection) new DataConnect().getConn();
- userdto = new UserDTO();
- userdto.setUsername(UserForm.getUsername());
- userdto.setUserpsw(UserForm.getUserpsw());
- userdto.setUseremail(UserForm.getUseremail());
- userdto.setUsertime(new DealString().getDateTime());
- System.out.println("sss");
- if(userdto != null || !userdto.equals("")){
- usermanager = new UserManager(conn);
- int i = usermanager.regist(userdto);
- if(i == 1){
- usermanager = new UserManager(conn);
- UserVO uservo = usermanager.login(userdto);
- if(uservo != null){
- System.out.println(uservo.getUsername());
- session = request.getSession();
- session.setAttribute("username", uservo);
- response.sendRedirect(request.getContextPath()+"/show/admin/registok.jsp");
- }else{
- response.sendRedirect(request.getContextPath()+"/show/admin/registerr.jsp");
- }
- }else{
- response.sendRedirect(request.getContextPath()+"/show/admin/registerr.jsp");
- }
- }
- conn.close();
- return null;
- }
- public ActionForward login(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) throws SQLException, IOException {
- UserForm UserForm = (UserForm) form;// TODO Auto-generated method stub
- conn = (Connection) new DataConnect().getConn();
- userdto = new UserDTO();
- userdto.setUsername(UserForm.getUsername());
- userdto.setUserpsw(UserForm.getUserpsw());
- System.out.println(userdto.getUsername());
- if(userdto != null || !userdto.equals("")){
- usermanager = new UserManager(conn);
- UserVO uservo = usermanager.login(userdto);
- if(uservo != null){
- session = request.getSession();
- session.setAttribute("username", uservo);
- response.sendRedirect(request.getContextPath()+"/show/admin/registok.jsp");
- }else{
- response.sendRedirect(request.getContextPath()+"/show/admin/registerr.jsp");
- }
- }
- conn.close();
- return null;
- }
- protected Map getKeyMethodMap() {
- // TODO Auto-generated method stub
- HashMap map = new HashMap();
- map.put("button.regist", "regist");
- map.put("button.login", "login");
- return map;
- }
- }