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

📄 domodifyaction.java

📁 图书商城系统
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.tang.struts.action;



import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

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

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

import com.tang.foruse.GetConn;
import com.tang.struts.form.ModifyForm;

/** 
 * ��֮ǰ���޸��û��������ƣ���action�����û��޸�����ľ��嶯���ת��
 * MyEclipse Struts
 * Creation date: 05-25-2008
 * 
 * XDoclet definition:
 * @struts.action validate="true"
 * @struts.action-forward name="failure" path="/login.jsp"
 * @struts.action-forward name="error" path="/modify.do"
 * @struts.action-forward name="success" path="/mydata.jsp"
 */
public class DomodifyAction extends Action {
	/*
	 * Generated Methods
	 */

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		// TODO Auto-generated method stub
		String target="failure";
		HttpSession session = request.getSession();
		ModifyForm mform = (ModifyForm)form;
		int id = mform.getUid();
		String newpassword = mform.getNewpassword();
		String username = (String)session.getAttribute("user");
		GetConn gc = new GetConn();
		Connection conn = null;
		PreparedStatement pstm = null;
		int i =0;
		if(username!=null)
		{
			conn = gc.GetConnectioon();
			try {
				pstm = conn.prepareStatement("update users set password='"+newpassword+"'where id="+id);
				i = pstm.executeUpdate();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}finally
			{
				try {
					if(pstm!=null)
					{
						pstm.close();
						pstm = null;
					}
					if(conn!=null&&!conn.isClosed()){
						conn.close();
						conn = null;
					}
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			if(i!=0)
			{

				target="success";
				System.out.println("seccuss");
			}
			else
			{
				target ="error";
				ActionErrors errors = new ActionErrors();
				ActionMessage msg = new ActionMessage("�����޸Ĵ���", false);
				errors.add("modify", msg);
				request.setAttribute(org.apache.struts.Globals.ERROR_KEY, errors);
				return mapping.findForward(target);
			}
		}
		else
		{
			ActionErrors errors = new ActionErrors();
			ActionMessage msg = new ActionMessage("����δ��¼�����ȵ�¼", false);
			errors.add("update", msg);
			request.setAttribute(org.apache.struts.Globals.ERROR_KEY, errors);
			return mapping.findForward(target);
		}
		return mapping.findForward(target);
	}
}

⌨️ 快捷键说明

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