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

📄 logfindbyprimarykeyaction.java

📁 STRUTS数据库项目开发宝典
💻 JAVA
字号:
package org.helpsoft.helplog.struts.actions;

import org.apache.struts.*;
import org.apache.struts.action.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.*;
import java.math.*;
import org.helpsoft.helplog.dao.*;
import org.helpsoft.helplog.dto.*;
import org.helpsoft.helplog.factory.*;
import org.helpsoft.helplog.struts.forms.*;

public class LogFindByPrimaryKeyAction extends Action
{
	/**
	 * method'execute'
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @throws Exception
	 * @return ActionForward
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
	{
		try {
			// parse parameters
			java.lang.String _logid = request.getParameter("logid");
		
			// create the DAO class
			LogDao dao = LogDaoFactory.create();
		
			// execute the finder
			Log dto = dao.findByPrimaryKey(_logid);
		
			// check that we have found a row
			if (dto == null) {
				throw new RuntimeException( "Finder did not return any data" );
			}
		
			String crudMethod = request.getParameter("crudMethod");
			if (crudMethod == null) {
				crudMethod = "view";
			}
		
			// populate a struts form
			LogForm logForm = new LogForm();
			logForm.setCrudMethod( request.getParameter("crudMethod") );
			logForm.setLogid(dto.getLogid());
			logForm.setLogtypecode(dto.getLogtypecode());
			logForm.setTitle(dto.getTitle());
			logForm.setContent(dto.getContent());
			logForm.setAuthor(dto.getAuthor());
			logForm.setDate(dto.getDate() == null ? null : DateFormat.getDateInstance().format( dto.getDate()));
			// store the results
			request.getSession().setAttribute( "Log", logForm );
		
			return mapping.findForward( crudMethod );
		}
		catch (Exception e) {
			ActionErrors _errors = new ActionErrors();
			_errors.add( ActionErrors.GLOBAL_ERROR, new ActionError("internal.error", e.getClass().getName() + ": " + e.getMessage() ) );
			saveErrors( request, _errors );
			return mapping.findForward( "failure" );
		}
		
	}

}

⌨️ 快捷键说明

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