customereditblogtypeaction.java
来自「基于struts的网上商店源码」· Java 代码 · 共 97 行
JAVA
97 行
/*
* 作者:管磊
* 时间:11-27-2007
* 功能:编辑会员的博客类型。
*/
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.CustomerAddSonDAO;
/**
* path: /customerEditBlogType writer : Singerinsky MyEclipse Struts Creation
* date: 11-28-2007
*
* XDoclet definition:
*
* @struts.action validate="true"
*/
public class CustomerEditBlogTypeAction extends Action {
/*
* Generated Methods
*/
private CustomerAddSonDAO 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 CustomerAddSonDAO();
String blogTypename = request.getParameter("blogTypename");// 博客类型名称
String blogTypeId = (request.getParameter("blogTypeid"));// 类型ID
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 blogloglist where typeid=" + blogTypeId;
sqls[1] = "delete from bloglogtype where id=" + blogTypeId;
dao.executeUpdate(sqls);// 执行删除操作。
ArrayList list = dao
.commonQuery("select * from bloglogtype where customerid="
+ userid);
// 重新获取博客类型
request.getSession().setAttribute("typelist", list);
return new ActionForward("/customerManagerBlogType.do");
} else if (blogTypename != null && blogTypeId != null)// 修改日志类型名称。
{
blogTypeId = blogTypeId.substring(blogTypeId.length() - 1,
blogTypeId.length());
sql = "update bloglogtype set name='" + blogTypename
+ "' where id=" + blogTypeId;
dao.executeUpdate(sql);
ArrayList list = dao
.commonQuery("select * from bloglogtype where customerid="
+ userid);
request.getSession().setAttribute("typelist", list);
} else// 添加新的日志文章类型。
{
sql = "insert into bloglogtype values('"
+ request.getSession().getAttribute("user").toString()
+ "','" + newBlogTypename + "')";
dao.executeUpdate(sql);
ArrayList list = dao
.commonQuery("select * from bloglogtype where customerid="
+ userid);
request.getSession().setAttribute("typelist", list);
}
return new ActionForward("/customerManagerBlogType.do");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?