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

📄 delquestionaction.java

📁 使用J2EE Struts开发的房地产信息咨询系统
💻 JAVA
字号:
/**
 * DelQuestionAction.java
 * 删除Question的Action Bean
 * @author usr
 */

package building;

import javax.sql.*;
import javax.servlet.ServletContext;
import javax.servlet.http.*;

import org.apache.struts.action.*;

public final class DelQuestionAction extends Action
{
	public ActionForward execute(
			ActionMapping mapping,
			ActionForm form,
			HttpServletRequest request,
			HttpServletResponse response
			)
	throws Exception
	{
		DynaActionForm questionIdForm = (DynaActionForm)form;
		
		Integer questionId = (Integer)questionIdForm.get("questionid");
				
		//
		HttpSession session = request.getSession();
		Admin thisAdmin = (Admin)session.getAttribute(Constants.ADMIN_INFO_KEY);
				
		//
		ServletContext context = servlet.getServletContext();
		DataSource dataSource = (DataSource)context.getAttribute(Constants.DATASOURCE_KEY);
		DB db = new DB(dataSource);
		//
		String PageForward = null;
		ActionMessages errors = new ActionMessages();
		
		if ( thisAdmin.getLev() != 1 )
		{
			//此用户无权限
			errors.add(ActionMessages.GLOBAL_MESSAGE,
					new ActionMessage("errors.adminNoRight2ADD"));
			if (!errors.isEmpty())
			{
				saveErrors(request,errors);
			}//End of if
			
			PageForward = "toWrong";
		}//End of if
		else
		{
			//此用户拥有权限
			if ( Question.delQuestion(db,questionId.intValue()) )
			{
				//删除成功
				PageForward = "toDelQuestionOK";
			}//End of if
			else
			{
				//添加失败
				errors.add(ActionMessages.GLOBAL_MESSAGE,
						new ActionMessage("errors.delQuestionFail"));
				if (!errors.isEmpty())
				{
					saveErrors(request,errors);
				}//End of if
				
				PageForward = "toWrong";
			}//End of else
		}//End of else
		
		//Close the Connection
		db.close();
		
		return(mapping.findForward(PageForward));
	}//End of execute
}//End of class DelQuestionAction

⌨️ 快捷键说明

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