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

📄 merchantstoreeditblogtypeaction.java

📁 基于struts的网上商店源码
💻 JAVA
字号:
/*
 * 作者:管磊
 * 时间:01-04-2008
 * 功能:编辑商家的博客类型
 */
package com.mole.struts.action;

import java.util.ArrayList;

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

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

import com.mole.struts.dao.MerchantBlogDao;

/**
 * MyEclipse Struts Creation date: 12-25-2007
 * 
 * XDoclet definition:
 * 
 * @struts.action validate="true"
 */
public class MerchantStoreEditBlogTypeAction extends Action {
	/*
	 * Generated Methods
	 */
	MerchantBlogDao dao;

	/**
	 * Method execute
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		String sql;
		if (dao == null)
			dao = new MerchantBlogDao();
		String blogTypename = request.getParameter("blogTypename");
		String blogTypeId = (request.getParameter("blogTypeid"));
		String newBlogTypename = request.getParameter("newTypename");
		Object ob = request.getSession().getAttribute("user");
		String userid = null;
		if (ob != null)
			userid = (ob).toString();
		if (blogTypename == null && blogTypeId != null)// 删除博客的类型,先删除所有的该类型的博客日志。
		{
			blogTypeId = blogTypeId.substring(blogTypeId.length() - 1,
					blogTypeId.length());
			String sqls[] = new String[2];
			sqls[0] = "delete from merchantStoreBlog where typeid="
					+ blogTypeId;
			sqls[1] = "delete from merchantStoreBlogType where id="
					+ blogTypeId;
			dao.executeUpdate(sqls);
			ArrayList list = null;
			try {
				list = dao.getMerchantBlogTypeById(userid);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			request.getSession().setAttribute("typelist", list);
			return new ActionForward("/merchantStoreBlogTypeManager.do");
		} else if (blogTypename != null && blogTypeId != null)// 更新博客的类型名称。
		{
			blogTypeId = blogTypeId.substring(blogTypeId.length() - 1,
					blogTypeId.length());
			sql = "update merchantStoreBlogType set name='" + blogTypename
					+ "' where id=" + blogTypeId;
			dao.executeUpdate(sql);
			ArrayList list = null;
			try {
				list = dao.getMerchantBlogTypeById(userid);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			request.getSession().setAttribute("typelist", list);

		} else {
			sql = "insert into merchantStoreBlogType values('"
					+ request.getSession().getAttribute("user").toString()
					+ "','" + newBlogTypename + "')";
			dao.executeUpdate(sql);
			ArrayList list = null;
			try {
				list = dao.getMerchantBlogTypeById(userid);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			request.getSession().setAttribute("typelist", list);

		}

		return new ActionForward("/merchantStoreBlogTypeManager.do");

	}
}

⌨️ 快捷键说明

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