customeraddtopicarticleaction.java

来自「基于struts的网上商店源码」· Java 代码 · 共 60 行

JAVA
60
字号
/*
 * 作者:管磊
 * 时间:2007年11月27日
 * 功能:添加会员博客主题文章
 */
package com.mole.struts.action;

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:/customerAddTopicArticle.do MyEclipse Struts Creation date: 11-27-2007
 * 
 * XDoclet definition:
 * 
 * @struts.action validate="true"
 */
public class CustomerAddTopicArticleAction extends Action {
	private CustomerAddSonDAO dao;

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		String userid = String.valueOf(request.getSession()
				.getAttribute("user"));
		String content = null;
		String title = null;
		String articleType = null;
		String state = request.getParameter("state");
		String insertSql = null;
		String nickname = request.getSession().getAttribute("nickname")
				.toString();
		if (userid == null)
			return new ActionForward("/index.jsp");// 验证
		if (dao == null)
			dao = new CustomerAddSonDAO();
		if (state == null) {

			return new ActionForward("/customerAddArticle.jsp");
		} else {
			content = request.getParameter("content");
			title = request.getParameter("title");
			articleType = request.getParameter("select");
			// 向数据库中插入会员博客文章。有内容,时间,标题,博客类型
			insertSql = "insert into blogloglist values('" + content
					+ "',getDate(),0," + userid + "," + articleType + ","
					+ content.length() + "," + "'" + title + "','" + nickname
					+ "')";
			dao.executeUpdate(insertSql);
			return new ActionForward("/customerGetBlogInfo.do");
		}

	}
}

⌨️ 快捷键说明

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