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

📄 java.txt

📁 网上招聘系统编码及其代码说明 不一定能运行通过
💻 TXT
📖 第 1 页 / 共 2 页
字号:


<%@ page language="java"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%> 
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
 
<html> 
	<head>
		<title>JSP for sampleForm form</title>
	</head>
	<body>
	<%-- 判断用户信息 --%>
	<logic:present name="SampleForm" property="userList" >
		<%-- 循环显示用户信息 --%>
		<logic:iterate id="user" name=" SampleForm " property="userList">
    		<tr>
        		<td><bean:write name="user" property="id" /></td>
        		<td><bean:write name="user" property="name" /></td>
      		</tr>
    	</logic:iterate> 
    </logic:present>

	</body>
</html>

 
8.目录规范
开发环境是eclipse,开发之后需要部署到Tomcat 服务器环境上。所以开发环境的目录结构与运行环境的目录结构是一致的,只是在部署的运行环境中,可以不设置源代码的目录。开发目录如图D-1。

 


编码过程应该按照详细设计的规划进行,在伪代码的基础上,按照编码标准和规范进行分模块编码。开发环境是eclipse,首先开发人员在开发过程中按照开发的目录将相应的文件存放在指定的目标下,进行调试,如果调试完成,代码评审通过后,放入基线库,再从基线库将代码放入运行(Tomcat)环境中。

各个目录的说明如下:
1)OnlineCV/src/share	目录中存放所有的JAVA公用的模块,详见基线库OnlineCV/src/share目录下文件,表D-2是公用模块中关于数据库的基本操作类的代码。

表D-2:数据库的基本操作

package com.changjiangcompany.struts.javashare;

import java.sql.*; 
import java.util.*; 
import com.microsoft.jdbcx.sqlserver.SQLServerDataSource; 

public class DBConnect {
	
	private Statement stmt=null; 
	private ResultSet rs=null; 
	
    public DBConnect(){
		try
{//初始化连接
			Class.forName(("com.microsoft.jdbc.sqlserver.SQLServerDriver"));  
		}catch(java.lang.ClassNotFoundException e){
			System.err.println("opendb():"+e.getMessage());
		}		
	}
    
    /**
	 * 方法:  executeQuery
	 * 描述:  执行查询记录操作
	 * 输入:  String strsql 要执行操作的sql语句
	 * @返回: ArrayList ArrayRs 查询的结果
	 * @异常处理:throws SQLException
	 */
    public ArrayList executeQuery(SQLServerDataSource source,String strSql) throws SQLException {
        Connection con=null; 
      	rs=null;
      	ArrayList ArrayRs=new ArrayList(); 
      	try{
      		con=source.getConnection();
      		stmt=con.createStatement();
      		rs=stmt.executeQuery(strSql);
      		
      		ResultSetMetaData rsmd=rs.getMetaData();
      		int numberOfColumns = rsmd.getColumnCount();
      		
//判断是否为空
      		if(!ArrayRs.isEmpty())
{
      				ArrayRs.clear();
      			}
      		
/*
      		 * 将每条记录写入ArrayList里
      		 */
      		 while(rs.next()){
      		 	ArrayList arrlist1=new ArrayList();
      		 	for(int j=1;j<=numberOfColumns;j++){
      		 		String s=rs.getString(j);
      		 		if(s==null){
      		 			s="";
      		 		}
      		 		arrlist1.add(s);
      		 	}
      		 	ArrayRs.add(arrlist1);
      		 	}
      		}catch(Exception e){
      			System.out.println("query error:" + e.getMessage());
      		}finally{
      		if (stmt != null) {
      			stmt.close();
      			}
      		if (con != null&&!con.isClosed()) {
      			con.close();
      			}
      	}
      	return ArrayRs;
      	
    }
    
    /**
	 * 方法:  executeInsert
	 * 描述:  执行插入记录操作
	 * 输入:  String strsql 要执行操作的sql语句
	 * 返回: boolean 插入操作是否正确执行
	 * 异常处理: SQLException
	 */
	public boolean executeInsert(SQLServerDataSource source,String strSql) throws SQLException{
       	Connection con=null; 
       	rs=null;
       	try{
       		con=source.getConnection();
       		stmt=con.createStatement();
       		
       		con.setAutoCommit(true);
       		int i=stmt.executeUpdate(strSql);
       		
       		if(i==1){
       			return (true);
       			}
       	}catch(Exception e){
       		System.out.println("Insert error:"+e.getMessage());
       	}finally{
      		if (stmt != null) {
      			stmt.close();
      			}
      		if (con != null&&!con.isClosed()) {
      			con.close();
      			}
      	}
       	return (false);
    }
    
    /**
	 * 方法:  executeUpdate
	 * 描述:  执行更新操作
	 * 输入:  String strsql 要执行操作的sql语句
	 * 返回: int 更新操作的记录数
	 * 异常处理: SQLException
	 */
	public int executeUpdate(SQLServerDataSource source,String strSql) throws SQLException{
		Connection con=null; 
		rs=null;
		int j=0;
		try{
          	con=source.getConnection();
          	stmt=con.createStatement();
          	con.setAutoCommit(false);
          	
          	j=stmt.executeUpdate(strSql);
          	if(j>0){
          		con.commit();
          		}else{
          			con.rollback();
          			}
          	}catch(Exception e){
          		System.out.println("update error:"+e.getMessage());
          	}finally{
          		if (stmt != null) {
      			    stmt.close();
      			    }
      		    if (con != null&&!con.isClosed()) {
      			    con.close();
      			   }
      	    }
        return j;
    }
    
    /**
	 * 方法:  executeDelete
	 * 描述:  执行删除操作
	 * 输入:  String strsql 要执行操作的sql语句
	 * 返回: int 删除操作的记录数
	 * 异常处理: throws SQLException
	 */
	public int executeDelete(SQLServerDataSource source,String strSql) throws SQLException{
		Connection con=null; 
		rs=null;
		int j=0;
        try{
        	con=source.getConnection();
        	stmt=con.createStatement();
         		
         	con.setAutoCommit(false);
         	j=stmt.executeUpdate(strSql);
         		
         	if(j>0){
         		con.commit();
          		con.rollback();
          		}
         	}catch(Exception e){
         		System.out.println("Delete error:"+e.getMessage());
         		}finally{
      		        if (stmt != null) {
      			        stmt.close();
      			        }
      		        if (con != null&&!con.isClosed()) {
      			        con.close();
      			       }
      	         }
         return j;
     } 


2)OnlineCV/src/Form目录中存放所有模块的form模块,详见基线库的OnlineCV/src/Form目录下文件,表D-3是职位管理中的formAddJobForm模块的代码。

表D-3:职位管理中的formAddJobForm模块的代码


package com.changjiangcompany.struts.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

/** 
 * MyEclipse Struts
 * Creation date: 04-16-2006
 * 
 * XDoclet definition:
 * @struts.form name="submitAnswerForm"
 */

public class SubmitAnswerForm extends ActionForm {

	// --------------------------------------------------------- Instance Variables

	/** 职位名称 */
	private String JobName;
	/** 职位发布日期 */
	private String PubDate;
	/** 职位发布结束日期 */
	private String EndDate;
	/** 职位描述 */
	private String Description;
	/** 职位要求 */
	private String Requirements;
	/** 招聘人数 */
	private int JobNum;


	// --------------------------------------------------------- Methods

	/** 
	 * Method validate
	 * @param mapping
	 * @param request
	 * @return ActionErrors
	 */
	public ActionErrors validate(
		ActionMapping mapping,
		HttpServletRequest request) 
	{

	。。。。。。
	}

	/** 
	 * Method reset
	 * @param mapping
	 * @param request
	 */
	public void reset(ActionMapping mapping, HttpServletRequest request) 
	{
	。。。。。。

	}

	/** 
	 * 返回 JobName.
	 * 
	 */
	public String getJobName() {
		return JobName;
	}

	/** 
	 * 赋值 JobName.
	 * 
	 */
	public void setJobName(String JobName) {
		this.JobName = JobName;
	}

	/** 
	 * 返回 PubDate.
	 * 
	 */
	public String getPubDate() {
		return PubDate;
	}

	/** 
	 * 赋值 PubDate.
	 * 
	 */
	public void setPubDate(String PubDate) {
		this.PubDate = PubDate;
	}


	/** 
	 * 返回 EndDate.
	 * 
	 */
	public String getEndDate() {
		return EndDate;
	}

	/** 
	 * 赋值 EndDate.
	 * 
	 */

	public void setPubDate(String EndDate) {
		this.EndDate = EndDate;
	}


	/** 
	 * 返回 Description.
	 * 
	 */
	public String getDescription() {
		return Description;
	}

	/** 
	 * 赋值 Description.
	 * 
	 */

	public void setDescription(String Description) {
		this.Description = Description;
	}

	/** 
	 * 返回 Requirements.
	 * 
	 */
	public String getRequirements() {
		return Requirements;
	}

	/** 
	 * 赋值 Requirements.
	 * 
	 */

	public void setRequirements(String Requirements) {
		this.Requirements = Requirements;
	}



	/** 
	 * 返回 JobNum.
	 * 
	 */
	public int getJobNum() {
		return JobNum;
	}

	/** 
	 * 赋值 JobNum.
	 * 
	 */
	public void setJobNum(int JobNum) {
		this.JobNum = JobNum;
	}
}

3)OnlineCV/src/ Action目录中存放所有模块的Action模块,详见基线库的OnlineCV/src/ Action目录下文件,表D-4是职位管理中的formAddJobAction模块的代码。

表D-4:职位管理中的formAddJobAction模块的代码


package com.changjiangcompany.struts.action;

import java.util.Vector;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.sql.DataSource;

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 org.apache.struts.action.DynaActionForm;

import share.Constants;
import com.changjiangcompany.DB;
import com.changjiangcompany.Job;

/**
 * MyEclipse Struts Creation date: 04-19-2006

⌨️ 快捷键说明

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