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

📄 settypeaction.java

📁 本书由浅入深、循序渐进地介绍了MVC的体系结构和如何构建一个基于MVC的Web框架
💻 JAVA
字号:
package com.myContent.action;

import java.sql.SQLException;
import java.util.List;

import org.apache.log4j.Logger;

import com.myContent.service.Login;
import com.myContent.service.Regedit;
import com.myContent.service.SetContentType;
import com.myContent.service.impl.LoginImpl;
import com.myContent.service.impl.RegeditImpl;
import com.myContent.service.impl.SetContentTypeImpl;
import com.myContent.vo.ContentType;
import com.myContent.vo.User;
import com.gd.mvc.action.impl.GdAction;
import com.gd.mvc.exception.VODataValidate;

public class SetTypeAction extends GdAction{
	static Logger logger = Logger.getLogger(SetTypeAction.class.getName());
	private ContentType contentType = null;

	public void doBegin() throws VODataValidate, Exception{
		//获取页面中的值
		contentType = (ContentType)infoIn.getVO();
		String username = infoIn.getParameter("username");
		if ("".equals(username) || username == null) {
			infoOut.put("forwardJsp", "login");
		}
		infoOut.put("username", username);
		String userId = infoIn.getParameter("userId");
		infoOut.put("userId", userId);
		infoOut.put("msg", "请输入内容类别Id和名称");
	}
	public void doEnd()  throws Exception{
		this.getAllType();
		infoOut.put("contentType", contentType);
	}
	
	/**该方法用来实现获取所有的内容类别
	*/
	public void getAllType() throws Exception{
		try {			
			SetContentType setContentType = new SetContentTypeImpl();
			//获取所有的内容类别	
			List contentTypeList = setContentType.getAllContentType();
			infoOut.put("contentTypeList", contentTypeList);
		} catch(Exception e) {
        	logger.error(e);
		} finally {
		}
  	}
	
	/**该方法用来实现新增内容类别
	*/
	public void doInsert() throws Exception{
		try {			
			SetContentType setContentType = new SetContentTypeImpl();
//			新增内容类别	
			int counts = setContentType.saveContentType(contentType);
			//判断是否新增成功
			if (counts != 0) {
				infoOut.put("msg", "新增成功");
			} else {
				infoOut.put("msg", "新增失败");
			}
		} catch(Exception e) {
        	logger.error(e);
		} finally {
		}
  	}
	/**该方法用来实现修改内容类别
	*/
	public void doUpdate() throws Exception{
		try {			
			SetContentType setContentType = new SetContentTypeImpl();
//			修改内容类别	
			int counts = setContentType.updateContentType(contentType);
			//判断是否修改成功
			if (counts != 0) {
				infoOut.put("msg", "修改成功");
			} else {
				infoOut.put("msg", "修改失败");
			}
		} catch(Exception e) {
        	logger.error(e);
		} finally {
		}
  	}
	/**该方法用来实现删除内容类别
	*/
	public void doDelete() throws Exception{
		try {			
			SetContentType setContentType = new SetContentTypeImpl();
//			删除内容类别	
			int counts = setContentType.deleteContentType(contentType);
			//判断是否删除成功
			if (counts != 0) {
				infoOut.put("msg", "删除成功");
			} else {
				infoOut.put("msg", "删除失败");
			}
		} catch(Exception e) {
        	logger.error(e);
		} finally {
		}
  	}
}

⌨️ 快捷键说明

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