课程设计
具备部分增、删、改、查功能,无JavaScrip,前端界面只有普通得表格,后端代买写这写着关系就写乱了。
Bean代码
AdminiUserBean.java(这个bean作废了,后面没用)
package com.linlin.bean;
public class AdminiUserBean {
private String admini_no;
private String admini_passwd;
public void setAdmini_no(String admini_no) {
this.admini_no=admini_no;
}
public void setAdmini_passwd(String admini_passwd) {
this.admini_passwd=admini_passwd;
}
public String getAdmini_no() {
return admini_no;
}
public String getAdmini_passwd() {
return admini_passwd;
}
}
ProjectAuditBean.java
package com.linlin.bean;
public class ProjectAuditBean {
private String rese_no;
private String rese_name;
private String check_projeckname;
private String check_projmoney;
private String check_start;
private String check_end;
private String check_status;
private String check_name;
private String check_no;
public void setRese_no(String rese_no) {
this.rese_no=rese_no;
}
public void setRese_name(String rese_name) {
this.rese_name=rese_name;
}
public void setCheck_projeckname(String check_projieckname) {
this.check_projeckname=check_projieckname;
}
public void setCheck_projmoney(String check_projmoney) {
this.check_projmoney=check_projmoney;
}
public void setCheck_start(String check_start) {
this.check_start=check_start;
}
public void setCheck_end(String check_end) {
this.check_end=check_end;
}
public void setCheck_status(String check_status) {
this.check_status=check_status;
}
public void setCheck_name(String check_name) {
this.check_name=check_name;
}
public void setCheck_no(String check_no) {
this.check_no=check_no;
}
public String getCheck_projeckname() {
return check_projeckname;
}
public String getCheck_projmoney() {
return check_projmoney;
}
public String getCheck_start() {
return check_start;
}
public String getCheck_end() {
return check_end;
}
public String getCheck_status() {
return check_status;
}
public String getCheck_name() {
return check_name;
}
public String getRese_no() {
return rese_no;
}
public String getRese_name() {
return rese_name;
}
public String getCheck_no() {
return check_no;
}
}
ResearchersBean.java
package com.linlin.bean;
public class ResearchersBean {
private String rese_no;
private String rese_name;
private String rese_sex;
private String rese_birthday;
private String rese_degree;
private String rese_profess;
private String rese_dapart;
private String total_paper;
private String total_rewark;
private String total_prizewinner;
public void setRese_no(String rese_no) {
this.rese_no=rese_no;
}
public void setRese_name(String rese_name) {
this.rese_name=rese_name;
}
public void setRese_sex(String rese_sex) {
this.rese_sex=rese_sex;
}
public void setRese_birthday(String rese_birthday) {
this.rese_birthday=rese_birthday;
}
public void setRese_degree(String rese_degree) {
this.rese_degree=rese_degree;
}
public void setRese_profess(String rese_profess) {
this.rese_profess=rese_profess;
}
public void setRese_dapart(String rese_dapart) {
this.rese_dapart=rese_dapart;
}
public void setTotal_paper(String total_paper) {
this.total_paper=total_paper;
}
public void setTotal_rewark(String total_rewark) {
this.total_rewark=total_rewark;
}
public void setTotal_prizewinner(String total_prizewinner) {
this.total_prizewinner= total_prizewinner;
}
public String getRese_no() {
return rese_no;
}
public String getRese_name() {
return rese_name;
}
public String getRese_sex() {
return rese_sex;
}
public String getRese_birthday() {
return rese_birthday;
}
public String getRese_degree() {
return rese_degree;
}
public String getRese_profess() {
return rese_profess;
}
public String getRese_dapart() {
return rese_dapart;
}
public String getTotal_paper() {
return total_paper;
}
public String getTotal_rewark() {
return total_rewark;
}
public String getTotal_prizewinner() {
return total_prizewinner;
}
}
ResearchersUserBean.java
package com.linlin.bean;
public class ResearchersUserBean {
private String rese_no;
private String rese_name;
private String rese_sex;
private String rese_birthday;
private String rese_degree;
private String rese_profess;
private String rese_dapart;
private String rese_passwd;
private String role;
public void setRese_no(String rese_no) {
this.rese_no=rese_no;
}
public void setRese_name(String rese_name) {
this.rese_name=rese_name;
}
public void setRese_sex(String rese_sex) {
this.rese_sex=rese_sex;
}
public void setRese_birthday(String rese_birthday) {
this.rese_birthday=rese_birthday;
}
public void setRese_degree(String rese_degree) {
this.rese_degree=rese_degree;
}
public void setRese_profess(String rese_profess) {
this.rese_profess=rese_profess;
}
public void setRese_dapart(String rese_dapart) {
this.rese_dapart=rese_dapart;
}
public void setRese_passwd(String rese_passwd) {
this.rese_passwd=rese_passwd;
}
public void setRole(String role) {
this.role=role;
}
public String getRese_no() {
return rese_no;
}
public String getRese_name() {
return rese_name;
}
public String getRese_sex() {
return rese_sex;
}
public String getRese_birthday() {
return rese_birthday;
}
public String getRese_degree() {
return rese_degree;
}
public String getRese_profess() {
return rese_profess;
}
public String getRese_dapart() {
return rese_dapart;
}
public String getRese_Passwd() {
return rese_passwd;
}
public String gerRole() {
return role;
}
}
UserBean.java
package com.linlin.bean;
public class UserBean {
private String rese_no;
private String rese_passwd;
public void setRese_no(String rese_no) {
this.rese_no=rese_no;
}
public void setRese_passwd(String rese_passwd) {
this.rese_passwd=rese_passwd;
}
public String getRese_no() {
return rese_no;
}
public String getRese_passwd() {
return rese_passwd;
}
}
Dao
BaseDao.java
package com.linlin.dao;
import java.sql.SQLException;
import java.util.List;
import com.linlin.bean.ProjectAuditBean;
import com.linlin.bean.ResearchersBean;
import com.linlin.bean.ResearchersUserBean;
public interface BaseDao<T> {
// /**
// * @param check_no
// * @return 通过check_no查询单个
// * @throws Exception
// */
T get(String rese_no) throws Exception;
/**
*
* @param check_status
* @return 未通过审核的项目
* @throws Exception
*/
List<T> getlist(String check_status) throws Exception;
/**
* @return 查询全部
* @throws Exception
*/
List<T> list() throws Exception;
/**
* @return 统计总数
* @throws Exception
*/
Integer count() throws Exception;
/**
* @param 研究院编号rese_no
* @return 指定研究院成果信息
* @throws Exception
*/
//T getreseinfo(String rese_no) throws Exception;
T getreseinfo(String rese_no) throws Exception;
T getreseproinfo(String rese_no) throws Exception;
boolean del(String rese_no) throws Exception;
}
ProjectAuditeDao.java
package com.linlin.dao;
import com.linlin.bean.ProjectAuditBean;
public interface ProjectAuditeDao extends BaseDao<ProjectAuditBean>{
}
ResearchersDao.java
package com.linlin.dao;
import com.linlin.bean.ResearchersBean;
public interface ResearchersDao extends BaseDao<ResearchersBean>{
}
ResearchersUserDao.java
package com.linlin.dao;
import com.linlin.bean.ResearchersBean;
public interface ResearchersUserDao extends BaseDao<ResearchersBean> {
}
ReseUserDao.java
package com.linlin.dao;
import java.sql.SQLException;
import com.linlin.bean.UserBean;
public interface UserDao {
/**
* @param user,role
* @return 返回登录是否成功
* @throws Exception
*/
UserBean findUser(UserBean user, String role) throws SQLException;
}
Dao.impl
BaseDaoImpl.java
package com.linlin.dao.impl;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.ScalarHandler;
import com.linlin.dao.BaseDao;
import com.linlin.dao.util.DataSourceUtil;
public abstract class BaseDaoImpl<T> implements BaseDao<T>{
/**
* 表名字
*/
protected String tableName = tableName();
/**
* 子类可以通过重写配置表名
*/
protected abstract String tableName();
/**
* 统计记录数
*/
@Override
public Integer count() throws Exception {
String sql = "SELECT COUNT(*) FROM " + tableName;
QueryRunner queryRunner = new QueryRunner(DataSourceUtil.getDataSource());
return queryRunner.query(sql, new ScalarHandler<Number>(1)).intValue();
}
}
ProjectAuditeDaoImpl.java
package com.linlin.dao.impl;
import java.sql.SQLException;
import java.util.List;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import com.linlin.bean.ProjectAuditBean;
import com.linlin.dao.ProjectAuditeDao;
import com.linlin.dao.util.DataSourceUtil;
public class ProjectAuditeDaoImpl extends BaseDaoImpl<ProjectAuditBean> implements ProjectAuditeDao{
@Override
public List<ProjectAuditBean> list() throws Exception {
// TODO 自动生成的方法存根
QueryRunner queryRunner = new QueryRunner(DataSourceUtil.getDataSource());
return (List<ProjectAuditBean>) queryRunner.query("select * from submitprojeckinfo", new BeanListHandler(ProjectAuditBean.class));
}
@Override
protected String tableName() {
// TODO 自动生成的方法存根
return "submitprojeckinfo";
}
@Override
public ProjectAuditBean get(String rese_no) throws Exception {
// TODO 自动生成的方法存根
QueryRunner queryRunner = new QueryRunner(DataSourceUtil.getDataSource());
return (ProjectAuditBean) queryRunner.query("select * from total_rese where rese_no=?", new BeanListHandler(ProjectAuditBean.class),rese_no);
}
@Override
public List<ProjectAuditBean> getlist(String check_status) throws Exception {
// TODO 自动生成的方法存根
QueryRunner queryRunner = new QueryRunner(DataSourceUtil.getDataSource());
return (List<ProjectAuditBean>) queryRunner.query("select * from submitprojeckinfo where check_status=?", new BeanListHandler(ProjectAuditBean.class),check_status);
}
public boolean update_aucheck(String status,String check_no) throws Exception {
QueryRunner queryRunner = new QueryRunner(DataSourceUtil.getDataSource());
int row=queryRunner.update("update aucheck set check_status=? where check_no=?",status,check_no);
System.out.println(row);
return row>=1;
}
// @Override
// public ProjectAuditBean get(String check_no) throws Exception {
// // TODO 自动生成的方法存根
// QueryRunner queryRunner = new QueryRunner(DataSourceUtil.getDataSource());
// return queryRunner.query("select * from submitprojeckinfo ", beanHandler);
// }
@Override
public ProjectAuditBean getreseinfo(String rese_no) throws Exception {
// TODO 自动生成的方法存根
return null;
}
public ProjectAuditBean getreseproinfo(String rese_no) throws SQLException {
QueryRunner queryRunner = new QueryRunner(DataSourceUtil.getDataSource());
return (ProjectAuditBean) queryRunner.query("select * from submitprojeckinfo where rese_no=?", new BeanHandler(ProjectAuditBean.class),rese_no);
}
@Override
public boolean del(String rese_no) throws Exception {
return false;
// TODO 自动生成的方法存根
}
}
ResearchersDaoImpl.java
package com.linlin.dao.impl;
import java.util.List;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import com.linlin.bean.ResearchersBean;
import com.linlin.dao.ResearchersDao;
import com.linlin.dao.util.DataSourceUtil;
public class ResearchersDaoImpl extends BaseDaoImpl<ResearchersBean> implements ResearchersDao{
@Override
public List<ResearchersBean> list() throws Exception {
// TODO 自动生成的方法存根
QueryRunner queryRunner = new QueryRunner(DataSourceUtil.getDataSource());
return (List<ResearchersBean>) queryRunner.query("select * from total_rese", new BeanListHandler(ResearchersBean.class));
}
@Override
protected String tableName() {
// TODO 自动生成的方法存根
return "total_rese";
}
@Override
public ResearchersBean get(String rese_no) throws Exception {
// TODO 自动生成的方法存根
QueryRunner queryRunner = new QueryRunner(DataSourceUtil.getDataSource());
return (ResearchersBean) queryRunner.query("select * from total_rese where rese_no=?",new BeanHandler(ResearchersBean.class),rese_no);
}
@Override
public List<ResearchersBean> getlist(String check_status) throws Exception {
// TODO 自动生成的方法存根
return null;
}
// public List<ResearchersBean> getreseinfo() throws Exception {
// return null;
// // TODO 自动生成的方法存根
QueryRunner queryRunner = new QueryRunner(DataSourceUtil.getDataSource());
return (List<ResearchersBean>) queryRunner.query("CALL total_researchers('114141');", new BeanListHandler(ResearchersBean.class));
// }
@Override
public ResearchersBean getreseinfo(String rese_no) throws Exception {
// TODO 自动生成的方法存根
QueryRunner queryRunner = new QueryRunner(DataSourceUtil.getDataSource());
return (ResearchersBean) queryRunner.query("select * from total_rese where rese_no=?", new BeanListHandler(ResearchersBean.class),rese_no);
}
@Override
public ResearchersBean getreseproinfo(String rese_no) throws Exception {
// TODO 自动生成的方法存根
return null;
}
@Override
public boolean del(String rese_no) throws Exception {
return false;
// TODO 自动生成的方法存根
}
}
ResearchersUserDaoImpl.java
package com.linlin.dao.impl;
import java.util.List;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import com.linlin.bean.ProjectAuditBean;
import com.linlin.bean.ResearchersBean;
import com.linlin.bean.ResearchersUserBean;
import com.linlin.dao.ResearchersUserDao;
import com.linlin.dao.util.DataSourceUtil;
public class ResearchersUserDaoImpl extends BaseDaoImpl<ResearchersBean> implements ResearchersUserDao{
@Override
public ResearchersBean get(String rese_no) throws Exception {
// TODO 自动生成的方法存根
return null;
}
@Override
public List<ResearchersBean> getlist(String check_status) throws Exception {
// TODO 自动生成的方法存根
return null;
}
public boolean insert_researchers(ResearchersUserBean userbean) throws Exception {
QueryRunner queryRunner = new QueryRunner(DataSourceUtil.getDataSource());
int row=queryRunner.update( "insert into researchers(rese_no,rese_name,rese_passwd,role,rese_sex,rese_birthday,rese_degree,rese_profess,rese_dapart) values(?,?,?,?,?,?,?,?,?)",
userbean.getRese_no(),userbean.getRese_name(),userbean.getRese_Passwd(),
userbean.gerRole(),userbean.getRese_sex(),userbean.getRese_birthday(),
userbean.getRese_degree(),userbean.getRese_profess(),userbean.getRese_dapart());
return row>=1;
}
@Override
public List<ResearchersBean> list() throws Exception {
// TODO 自动生成的方法存根
return null;
}
@Override
protected String tableName() {
// TODO 自动生成的方法存根
return "researchers";
}
@Override
public ResearchersBean getreseinfo(String rese_no) throws Exception {
// TODO 自动生成的方法存根
return null;
}
@Override
public ResearchersBean getreseproinfo(String rese_no) throws Exception {
// TODO 自动生成的方法存根
return null;
}
@Override
public boolean del(String rese_no) throws Exception {
return false;
// TODO 自动生成的方法存根
}
}
UserDaoImpl.java
package com.linlin.dao.impl;
import java.sql.SQLException;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import com.linlin.bean.UserBean;
import com.linlin.dao.UserDao;
import com.linlin.dao.util.DataSourceUtil;
public class UserDaoImpl implements UserDao {
@Override
public UserBean findUser(UserBean user, String role) throws SQLException {
// TODO 自动生成的方法存根
QueryRunner queryRunner = new QueryRunner(DataSourceUtil.getDataSource());
//String sql = "select * from administrator where admini_no=? and admini_passwd=?";
String sql = "select * from researchers where rese_no=? and rese_passwd=? and role=?";
UserBean isuser = (UserBean) queryRunner.query(sql, new BeanHandler(UserBean.class), new Object[] {user.getRese_no(),user.getRese_passwd(),role});
return isuser;
}
}
dao.util
DataSourceUtil.java
package com.linlin.dao.util;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;
import javax.sql.DataSource;
import org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory;
public class DataSourceUtil {
private static DataSource ds;
/**
* 获取数据源
*/
public static DataSource getDataSource() {
return ds;
}
/**
* 获取数据库连接
* @throws SQLException
*/
public static Connection getConnection() throws SQLException {
return ds.getConnection();
}
/**
* 初始化
*/
static {
//c3p0
// ds = new ComboPooledDataSource("dev");
//dbcp
try(InputStream is = DataSourceUtil.class.getClassLoader().getResourceAsStream("dbcp.properties")) {
Properties props = new Properties();
props.load(is);
ds = BasicDataSourceFactory.createDataSource(props);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 测试
*/
public static void main(String[] args) throws SQLException {
System.out.println(getConnection().getMetaData());
}
}
filter
package com.linlin.filter;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
@WebFilter("/*")
public class CharacterFilter implements Filter {
public void init(FilterConfig filterConfig) throws ServletException {
}
public void doFilter(ServletRequest req, ServletResponse resp,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) resp;
// 拦截所有的请求 解决全站中文乱码
// 指定 request 和 response 的编码
request.setCharacterEncoding("utf-8"); // 只对消息体有效
//响应消息
response.setContentType("text/html;charset=utf-8");
// 对request进行包装
CharacterRequest characterRequest = new CharacterRequest(request);
chain.doFilter(characterRequest, response);
}
public void destroy() {
}
}
// 继承 默认包装类HttpServletRequestWrapper
// 解决Tomcat 7 下get请求乱码
class CharacterRequest extends HttpServletRequestWrapper {
public CharacterRequest(HttpServletRequest request) {
super(request);
}
// 子类继承父类一定会覆写一些方法,此处用于重写getParamter()方法
public String getParameter(String name) {
// 调用被包装对象的getParameter()方法,获得请求参数
String value = super.getParameter(name);
if (value == null)
return null;
// 判断请求方式
String method = super.getMethod();
if ("get".equalsIgnoreCase(method)) {
try {
value = new String(value.getBytes("iso-8859-1"), "utf-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
// 解决乱码后返回结果
return value;
}
}
service
BaseService.java
package com.linlin.service;
import java.util.List;
public interface BaseService<T> {
/**
* 查询单个
*/
T get(String check_no) throws Exception;
T getreseinfo(String rese_no) throws Exception;
/**
* 查询全部
*/
List<T> list() throws Exception;
/**
* 查询个数
*/
int count() throws Exception;
}
LoginService.java
package com.linlin.service;
import java.sql.SQLException;
import com.linlin.bean.UserBean;
public interface LoginService {
boolean login(UserBean user, String role) throws SQLException;
}
RegisterResearchersService.java
package com.linlin.service;
import java.sql.SQLException;
import com.linlin.bean.UserBean;
public interface RegisterResearchersService {
boolean insert(UserBean user, String role) throws SQLException;
}
ResearchersService.java
package com.linlin.service;
import java.sql.SQLException;
import com.linlin.bean.ResearchersBean;
public interface ResearchersService extends BaseService<ResearchersBean>{
boolean query(ResearchersBean userinfo,String rese_no) throws SQLException;
}
Service.impl
BaseServiceImpl.java
package com.linlin.service.impl;
import java.util.List;
import com.linlin.dao.BaseDao;
import com.linlin.service.BaseService;
public abstract class BaseServiceImpl<T> implements BaseService<T>{
protected BaseDao<T> dao = getDao();
/**
* 由子类实现
*/
protected abstract BaseDao<T> getDao() ;
@Override
public List<T> list() throws Exception {
// TODO 自动生成的方法存根
return dao.list();
}
@Override
public int count() throws Exception {
// TODO 自动生成的方法存根
return dao.count();
}
}
LoginServiceImpl.java
package com.linlin.service.impl;
import java.sql.SQLException;
import com.linlin.bean.UserBean;
import com.linlin.dao.impl.UserDaoImpl;
import com.linlin.service.LoginService;
public class LoginServiceImpl implements LoginService {
UserDaoImpl us = new UserDaoImpl();
@Override
public boolean login(UserBean user, String role) throws SQLException {
// TODO 自动生成的方法存根
UserBean isUser = us.findUser(user,role);
if (isUser==null) {
return false;
}
else {
return true;
}
}
}
ProjectAuditeServiceImpl.java
package com.linlin.service.impl;
import com.linlin.bean.ProjectAuditBean;
import com.linlin.dao.BaseDao;
import com.linlin.dao.impl.ProjectAuditeDaoImpl;
public class ProjectAuditeServiceImpl extends BaseServiceImpl<ProjectAuditBean>{
@Override
protected BaseDao<ProjectAuditBean> getDao() {
// TODO 自动生成的方法存根
return new ProjectAuditeDaoImpl();
}
@Override
public ProjectAuditBean get(String check_no) throws Exception {
// TODO 自动生成的方法存根
return null;
}
@Override
public ProjectAuditBean getreseinfo(String rese_no) throws Exception {
// TODO 自动生成的方法存根
return null;
}
}
ResearcherServiceImpl.java
package com.linlin.service.impl;
import java.sql.SQLException;
import java.util.List;
import com.linlin.bean.ResearchersBean;
import com.linlin.dao.BaseDao;
import com.linlin.service.ResearchersService;
public class ResearchersServiceImpl extends BaseServiceImpl<ResearchersBean> implements ResearchersService {
@Override
public ResearchersBean get(String check_no) throws Exception {
// TODO 自动生成的方法存根
return null;
}
@Override
public ResearchersBean getreseinfo(String rese_no) throws Exception {
// TODO 自动生成的方法存根
return null;
}
@Override
public boolean query(ResearchersBean userinfo, String rese_no) throws SQLException {
// TODO 自动生成的方法存根
return false;
}
@Override
protected BaseDao<ResearchersBean> getDao() {
// TODO 自动生成的方法存根
return null;
}
}
servlet
BaseServlet.java
package com.linlin.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public abstract class BaseServlet extends HttpServlet {
/**
* 转发请求
* @param request
* @param response
* @param path 转发的/WEB-INF/page/下的目标资源,参数值不含/WEB-INF/page/ 部分
* @throws ServletException
* @throws IOException
*/
protected void forward(HttpServletRequest request, HttpServletResponse response, String path)
throws ServletException, IOException {
request.getRequestDispatcher(path).forward(request, response);
}
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO 自动生成的方法存根
this.doGet(req, resp);
}
}
CheckServlet.java
package com.linlin.servlet;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.linlin.bean.ProjectAuditBean;
import com.linlin.dao.BaseDao;
import com.linlin.dao.impl.ProjectAuditeDaoImpl;
@WebServlet("/CheckServlet")
public class CheckServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO 自动生成的方法存根
BaseDao<ProjectAuditBean> service = new ProjectAuditeDaoImpl();
List<ProjectAuditBean> alltable;
try {
alltable = service .getlist("审核中");
System.out.println("审核中");
req.setAttribute("datas", alltable);
forward(req,resp,"/check.jsp");
} catch (Exception e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
/**
* 转发请求
* @param request
* @param response
* @param path 转发的/WEB-INF/page/下的目标资源,参数值不含/WEB-INF/page/ 部分
* @throws ServletException
* @throws IOException
*/
protected void forward(HttpServletRequest request, HttpServletResponse response, String path)
throws ServletException, IOException {
request.getRequestDispatcher(path).forward(request, response);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO 自动生成的方法存根
this.doGet(req, resp);
}
}
DeleteServlet.java
package com.linlin.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.linlin.dao.impl.ReseUserDaoImpl;
@WebServlet("/DeleteServlet")
public class DeleteServlet extends BaseServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO 自动生成的方法存根
String rese_no = req.getParameter("rese_no");
ReseUserDaoImpl rudi = new ReseUserDaoImpl();
System.out.println("开始删除"+rese_no);
try {
if(rudi.del(rese_no)) {
System.out.println("删除成功");
req.setAttribute("dele","删除成功");
forward(req, resp, "/QueryReseinfoServlet");
}
else {
req.setAttribute("dele","删除失败");
forward(req, resp, "/QueryReseinfoServlet");
}
} catch (Exception e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO 自动生成的方法存根
this.doGet(req, resp);
}
}
LoginServlet.java
package com.linlin.servlet;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.linlin.bean.ProjectAuditBean;
import com.linlin.bean.ResearchersBean;
import com.linlin.bean.UserBean;
import com.linlin.dao.BaseDao;
import com.linlin.dao.ProjectAuditeDao;
import com.linlin.dao.impl.ProjectAuditeDaoImpl;
import com.linlin.dao.impl.ResearchersDaoImpl;
import com.linlin.service.impl.LoginServiceImpl;
@WebServlet("/loginServlet")
public class LoginServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String username = req.getParameter("username");
String password = req.getParameter("password");
UserBean user = new UserBean();
user.setRese_no(username);
user.setRese_passwd(password);
System.out.println(user.getRese_no());
LoginServiceImpl userimpl = new LoginServiceImpl();
//判断权限获取选项值
String role = req.getParameter("access");
System.out.println(role);
try {
if (userimpl.login(user,role)) {
//判断用户权限
if(role.equals("1")){
BaseDao<ProjectAuditBean> service = new ProjectAuditeDaoImpl();
List<ProjectAuditBean> alltable = service .list();
System.out.println(alltable);
System.out.println(alltable.get(0).getCheck_no());
System.out.println(alltable.get(1).getCheck_no());
req.setAttribute("datas", alltable);
req.getSession().setAttribute("user", user);
forward(req,resp,"/admini.jsp");
}
else {
BaseDao<ResearchersBean> service = new ResearchersDaoImpl();
ResearchersBean alltable = service .get(username);
System.out.println(alltable);
System.out.println(alltable.getRese_no());
req.setAttribute("datas", alltable);
req.getSession().setAttribute("user", user);
forward(req,resp,"/reselogin.jsp");
//resp.sendRedirect(req.getContextPath()+"/reselogin.jsp");
}
//HttpSession session = req.getSession();
} else {
if(role.equals("1")) {
req.setAttribute("errerMsg","非管理员账户或用户名或密码错误");
} else {
req.setAttribute("errerMsg","非教师账户或用户名或密码错误");
req.getRequestDispatcher("login.jsp").forward(req, resp);
}
req.getRequestDispatcher("login.jsp").forward(req, resp);
}
} catch (SQLException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
} catch (ServletException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
} catch (Exception e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
/**
* 转发请求
* @param request
* @param response
* @param path 转发的/WEB-INF/page/下的目标资源,参数值不含/WEB-INF/page/ 部分
* @throws ServletException
* @throws IOException
*/
protected void forward(HttpServletRequest request, HttpServletResponse response, String path)
throws ServletException, IOException {
request.getRequestDispatcher(path).forward(request, response);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
this.doPost(req, resp);
}
}
LogouServlet.java
package com.linlin.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/LogoutServlet")
public class LogouServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO 自动生成的方法存根
req.getSession().removeAttribute("user");
resp.sendRedirect(req.getContextPath()+"/login.jsp");
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO 自动生成的方法存根
this.doGet(req, resp);
}
}
QueryReseinfoServlet.java
package com.linlin.servlet;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.linlin.bean.ResearchersUserBean;
import com.linlin.dao.BaseDao;
import com.linlin.dao.impl.ReseUserDaoImpl;
import com.linlin.dao.impl.ResearchersUserDaoImpl;
@WebServlet("/QueryReseinfoServlet")
public class QueryReseinfoServlet extends BaseServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO 自动生成的方法存根
ResearchersUserDaoImpl rud = new ResearchersUserDaoImpl();
BaseDao<ResearchersUserBean> service = new ReseUserDaoImpl();
List<ResearchersUserBean> alltable;
try {
alltable = service .list();
System.out.println(alltable);
// System.out.println(alltable.get(0).getRese_no());
// System.out.println(alltable.get(1).getRese_no());
req.setAttribute("datas", alltable);
forward(req,resp,"/reseinfo.jsp");
} catch (Exception e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO 自动生成的方法存根
this.doGet(req, resp);
}
}
QueryServlet.java
package com.linlin.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.linlin.bean.ResearchersBean;
import com.linlin.dao.BaseDao;
import com.linlin.dao.impl.ResearchersDaoImpl;
@WebServlet("/QueryServlet")
public class QueryServlet extends HttpServlet{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO 自动生成的方法存根
String user_no = req.getParameter("rese_no");
System.out.println("开始查询"+user_no);
BaseDao<ResearchersBean> service = new ResearchersDaoImpl();
ResearchersBean alltable;
try {
alltable = service .get(user_no);
if(alltable!=null) {
System.out.println(user_no);
System.out.println(alltable.getRese_no());
req.setAttribute("datas", alltable);
forward(req,resp,"/query.jsp");
}
else {
req.setAttribute("error","没有该人员");
forward(req,resp,"/query.jsp");
}
} catch (Exception e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
/**
* 转发请求
* @param request
* @param response
* @param path 转发的/WEB-INF/page/下的目标资源,参数值不含/WEB-INF/page/ 部分
* @throws ServletException
* @throws IOException
*/
protected void forward(HttpServletRequest request, HttpServletResponse response, String path)
throws ServletException, IOException {
request.getRequestDispatcher(path).forward(request, response);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO 自动生成的方法存根
this.doGet(req, resp);
}
}
RegisterServlet.java
package com.linlin.servlet;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import com.linlin.bean.ResearchersUserBean;
import com.linlin.dao.impl.ResearchersUserDaoImpl;
@WebServlet("/Register")
public class RegisterServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO 自动生成的方法存根;
System.out.println("register");
ResearchersUserDaoImpl reg = new ResearchersUserDaoImpl();
Map<String,String[]> map = req.getParameterMap();
ResearchersUserBean user = new ResearchersUserBean();
try {
BeanUtils.populate(user,map);
} catch (IllegalAccessException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
System.out.println(user.getRese_name());
System.out.println(user.getRese_no());
//开始插入数据库
try {
if(reg.insert_researchers(user)) {
System.out.println("注册成功");
req.setAttribute("info","研究员"+user.getRese_name()+"注册成功");
req.getRequestDispatcher("register.jsp").forward(req, resp);
}
} catch (Exception e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
/**
* 转发请求
* @param request
* @param response
* @param path 转发的/WEB-INF/page/下的目标资源,参数值不含/WEB-INF/page/ 部分
* @throws ServletException
* @throws IOException
*/
protected void forward(HttpServletRequest request, HttpServletResponse response, String path)
throws ServletException, IOException {
request.getRequestDispatcher(path).forward(request, response);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO 自动生成的方法存根
this.doGet(req, resp);
}
}
RereProServlet.jva
package com.linlin.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.linlin.bean.ProjectAuditBean;
import com.linlin.bean.UserBean;
import com.linlin.dao.BaseDao;
import com.linlin.dao.impl.ProjectAuditeDaoImpl;
@WebServlet("/ReseServlet")
public class ReseProServlet extends BaseServlet{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO 自动生成的方法存根
HttpSession session = req.getSession();
UserBean user = (UserBean) session.getAttribute("user");
ProjectAuditeDaoImpl padi = new ProjectAuditeDaoImpl();
System.out.println("登录用户"+user.getRese_no());
try {
BaseDao<ProjectAuditBean> service = new ProjectAuditeDaoImpl();
ProjectAuditBean alltable = service.getreseproinfo(user.getRese_no());
req.setAttribute("datas", alltable);
forward(req,resp,"/resepro.jsp");
} catch (Exception e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO 自动生成的方法存根
this.doGet(req, resp);
}
}
UpdateServlet.java
package com.linlin.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.linlin.dao.impl.ProjectAuditeDaoImpl;
@WebServlet("/UpdateServlet")
public class UpdateServlet extends HttpServlet{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO 自动生成的方法存根
ProjectAuditeDaoImpl padi = new ProjectAuditeDaoImpl();
String check = req.getParameter("check");
String check_no = req.getParameter("check_no");
System.out.println(check_no);
if(check==null) {
return;
}
System.out.println(check);
if(check.equals("yes")) {
try {
System.out.println("更新");
padi.update_aucheck("通过", check_no);
} catch (Exception e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
req.setAttribute("updatesuccess","更新成功");
forward(req, resp, "/CheckServlet");
}
else if(check.equals("no")) {
System.out.println("更新no");
try {
padi.update_aucheck("不予通过", check_no);
} catch (Exception e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
forward(req, resp, "/CheckServlet");
}
else {
System.out.println("waiting");
forward(req, resp, "/CheckServlet");
//forward(req, resp, "/CheckServlet");
}
}
/**
* 转发请求
* @param request
* @param response
* @param path
* @throws ServletException
* @throws IOException
*/
protected void forward(HttpServletRequest request, HttpServletResponse response, String path)
throws ServletException, IOException {
request.getRequestDispatcher(path).forward(request, response);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO 自动生成的方法存根
this.doGet(req, resp);
}
}
配置文件
#连接设置
driverClassName=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/gxkygl?useSSL=false&serverTimezone=CST&characterEncoding=utf-8
username=root
password=123456
#初始化连接
initialSize=5
#最大连接数量
maxActive=10
#最大空闲连接
maxIdle=3000
JSP
admini.jsp
在这里插入代<%@ page language="java" contentType="text/html;charset=UTF-8" language="java"
pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body style="text-align:center;">
<h1>管理员界面</h1>
<span>管理员:${user.rese_no }</span><a href="${pageContext.request.contextPath }/LogoutServlet">注销</a>
<br>
<div style="margin:0 auto">
<form action="${pageContext.request.contextPath }/CheckServlet" method="post" >
<input type="submit" value="开始审核" />
</form><br />
<form action="${pageContext.request.contextPath }/register.jsp" method="post" >
<input type="submit" value="注册研究员" />
</form>
<form action="${pageContext.request.contextPath }/QueryReseinfoServlet">
<input type="submit" value="查询教师基本信息"/>
</form>
<form action="${pageContext.request.contextPath }/QueryServlet" method="post" >
<label>请输入研究人员编号</label>
<input type="text" name="rese_no" />
<input type="submit" value="查询研究人员信息" />
</form>
</div>
<div style="margin:0 auto">
<table border="1" cellspacing="0" style="margin:0 auto">
<caption><h3>审核表</h3></caption>
<tr>
<td><h3>审核号</h3></td>
<td><h3>项目名</h3></td>
<td><h3>研究员姓名</h3></td>
<td><h3>项目经费</h3></td>
<td><h3>项目启动时间</h3></td>
<td><h3>项目状态</h3></td>
<td><h3>项目结束时间</h3></td>
<td><h3>审核人员</h3></td>
</tr>
<c:forEach items="${datas}" var="item">
<tr>
<td>${item.check_no }</td>
<td>${item.rese_name }</td>
<td>${item.check_projeckname }</td>
<td>${item.check_projmoney }</td>
<td>${item.check_start }</td>
<td>${item.check_status }</td>
<td>${item.check_end }</td>
<td>${item.check_name }</td>
</tr>
</c:forEach>
</table>
</div>
</body>
</html>
码片
check.jsp
<%@ page language="java" contentType="text/html;charset=UTF-8" language="java"
pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body style="text-align:center;">
<h1>管理员界面</h1>
<span>管理员:${user.rese_no }</span><a href="${pageContext.request.contextPath }/LogoutServlet">注销</a>
<br>
<div style="margin:0 auto">
<table border="1" cellspacing="0" style="margin:0 auto">
<caption><h3>待审核表</h3></caption>
<tr>
<td><h3>序号</h3></td>
<td><h3>审核号</h3></td>
<td><h3>项目名</h3></td>
<td><h3>研究员姓名</h3></td>
<td><h3>项目经费</h3></td>
<td><h3>项目提交时间</h3></td>
<td><h3>项目状态</h3></td>
<td><h3>审核人员</h3></td>
<td><h3>是否通过</h3></td>
</tr>
<c:forEach items="${datas}" var="item">
<tr>
<td>${status.count }</td>
<td>${item.check_no }</td>
<td>${item.rese_name }</td>
<td>${item.check_projeckname }</td>
<td>${item.check_projmoney }</td>
<td>${item.check_start }</td>
<td>${item.check_status }</td>
<td>${item.check_name }</td>
<td><form action="${pageContext.request.contextPath }/UpdateServlet" method="post">
<select name="check_no" id="access" lay-verify="required">
<option value="${item.check_no }">审核号</option>
</select>
<input type="radio" name="check" value="yes" />通过
<input type="radio" name="check" value="no" />不予通过
<input type="radio" name="check" value="waiting" />待讨论
<input type="submit" value="提交" />
</form></td>
</tr>
</c:forEach>
</table>
</div>
</body>
</html>
login.jsp
<%@ page language="java" contentType="text/html;charset=UTF-8"
pageEncoding="UTF-8" %>
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<title>登录页面</title>
</head>
<body style="text-align:center">
<h2 style="color:red;">${errerMsg }</h2>
<form action="${pageContext.request.contextPath }/loginServlet" metho="post" />
<table border="1" width="600px" cellpadding="0" cellspacing="0" align="center">
<tr>
<td height="30" align="center">用户名</td>
<td>
<input type="text" name="username" /></td>
</tr>
<tr>
<td height="30" align="center">密 码</td>
<td>
<input type="password" name="password" /></td>
</tr>
<tr>
<td height="30" colspan="2" align="center">
<input type="submit" value="登录" />
<select name="access" id="access" lay-verify="required">
<option value="1">管理员</option>
<option value="2">教师</option>
</select>
</td>
</tr>
</table>
</body>
</html>
query.jsp
<%@ page language="java" contentType="text/html;charset=UTF-8" language="java"
pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body style="text-align:center;">
<h1>管理员界面</h1>
<span>管理员:${user.rese_no }</span><a href="${pageContext.request.contextPath }/LogoutServlet">注销</a>
<br>
<div style="margin:0 auto">
<h3 style="color:red;">${error }</h3>
<form action="${pageContext.request.contextPath }/QueryServlet" method="post" >
<label>请输入研究人员编号</label>
<input type="text" name="rese_no" />
<input type="submit" value="查询研究人员信息" />
</form>
</div>
<div style="margin:0 auto">
<table border="1" cellspacing="0" style="margin:0 auto">
<caption><h3>研究人员信息表</h3></caption>
<tr>
<td>编号</td>
<td>姓名</td>
<td>性别</td>
<td>出生日期</td>
<td>学位</td>
<td>职称</td>
<td>部门</td>
<td>发表论文数</td>
<td>获奖数</td>
<td>出版著作数</td>
</tr>
<tr>
<td>${datas.rese_no }</td>
<td>${datas.rese_name }</td>
<td>${datas.rese_sex }</td>
<td>${datas.rese_birthday }</td>
<td>${datas.rese_degree }</td>
<td>${datas.rese_profess }</td>
<td>${datas.rese_dapart }</td>
<td>${datas.total_paper }</td>
<td>${datas.total_rewark }</td>
<td>${datas.total_prizewinner }</td>
</tr>
</table>
</div>
</body>
</html>
register.jsp
<%@ page language="java" contentType="text/html;charset=UTF-8" language="java"
pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body style="text-align:center">
<h2 style="color:red;">研究员注册</h2>
<span>管理员:${user.rese_no }</span><a href="${pageContext.request.contextPath }/LogoutServlet">注销</a>
<h3 style="color:blue;">${info }</h3>
<form action="${pageContext.request.contextPath }/Register" method="post" >
<table border="1" width="600px" cellpadding="0" cellspacing="0" align="center">
<tr>
<td height="30" align="center">姓名</td>
<td>
<input type="text" name="rese_name" /></td>
</tr>
<tr>
<td height="30" align="center">账号</td>
<td>
<input type="text" name="rese_no" /></td>
</tr>
<tr>
<td height="30" align="center">密码</td>
<td>
<input type="password" name="rese_passwd" /></td>
</tr>
<tr>
<td height="30" align="center">权限</td>
<td>
<select name="role" id="access" lay-verify="required">
<option value="1">管理员</option>
<option value="2">教师</option>
</select>
</td>
</tr>
<tr>
<td height="30" align="center">性别</td>
<td>
<select name="rese_sex" id="access" lay-verify="required">
<option value="1">男</option>
<option value="2">女</option>
</select>
</td>
</tr>
<tr>
<td height="30" align="center">出生日期</td>
<td>
<input type="date" name="rese_birthday" /></td>
<input name="birthday" id="date1" autocomplete="off" class="layui-input" type="text">
</tr>
<tr>
<td height="30" align="center">学位</td>
<td>
<input type="text" name="rese_degree" /></td>
</tr>
<tr>
<td height="30" align="center">职称</td>
<td>
<input type="text" name="rese_profess" /></td>
</tr>
<tr>
<td height="30" align="center">部门</td>
<td>
<input type="text" name="rese_dapart" /></td>
</tr>
<tr>
<td height="30" colspan="2" align="center">
<input type="submit" value="注册" />
</td>
</tr>
</table>
</form>
</body>
</html>
reseinfo.jsp
<%@ page language="java" contentType="text/html;charset=UTF-8" language="java"
pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body style="text-align:center;">
<h1>管理员界面</h1>
<span>管理员:${user.rese_no }</span><a href="${pageContext.request.contextPath }/LogoutServlet">注销</a>
<br>
<div style="margin:0 auto">
<h3 style="color:blue;">${dele }</h3>
</div>
<div style="margin:0 auto">
<table border="1" cellspacing="0" style="margin:0 auto">
<caption><h3>人员信息表</h3></caption>
<tr>
<td><h3>编号</h3></td>
<td><h3>姓名名</h3></td>
<td><h3>性别</h3></td>
<td><h3>出生日期</h3></td>
<td><h3>学位</h3></td>
<td><h3>职称</h3></td>
<td><h3>部门</h3></td>
</tr>
<c:forEach items="${datas}" var="item">
<tr>
<td>${item.rese_no }</td>
<td>${item.rese_name }</td>
<td>${item.rese_sex }</td>
<td>${item.rese_birthday }</td>
<td>${item.rese_degree }</td>
<td>${item.rese_profess }</td>
<td>${item.rese_dapart }</td>
<td>
<form action="${pageContext.request.contextPath }/DeleteServlet" method="post">
<select name="rese_no" id="access" lay-verify="required">
<option value="${item.rese_no }">编号</option>
</select>
<input type="submit" name="check" value="删除" />
</form></td>
</tr>
</c:forEach>
</table>
</div>
</body>
</html>
reselogin.jsp
<%@ page language="java" contentType="text/html;charset=UTF-8" language="java"
pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<title>教师登录界面</title>
</head>
<body style="text-align:center;">
<h1>教师登录界面</h1>
<span>研究员:${user.rese_no }</span><a href="${pageContext.request.contextPath }/LogoutServlet">注销</a>
<div style="test-align:center;">
<form action="${pageContext.request.contextPath }/ReseServlet" method="post" >
<input type="submit" value="查询研究人员信息" />
</form>
<table border="1" width="600px" cellpadding="0" cellspacing="0" align="center">
<tr>
<td>编号</td>
<td>姓名</td>
<td>性别</td>
<td>出生日期</td>
<td>学位</td>
<td>职称</td>
<td>部门</td>
<td>发表论文数</td>
<td>获奖数</td>
<td>出版著作数</td>
</tr>
<tr>
<td>${datas.rese_no }</td>
<td>${datas.rese_name }</td>
<td>${datas.rese_sex }</td>
<td>${datas.rese_birthday }</td>
<td>${datas.rese_degree }</td>
<td>${datas.rese_profess }</td>
<td>${datas.rese_dapart }</td>
<td>${datas.total_paper }</td>
<td>${datas.total_rewark }</td>
<td>${datas.total_prizewinner }</td>
</td>
</table>
</div>
</body>
</html>
resepro.jsp
<%@ page language="java" contentType="text/html;charset=UTF-8" language="java"
pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body style="text-align:center;">
<h1>教师界面</h1>
<span>研究员:${user.rese_no }</span><a href="${pageContext.request.contextPath }/LogoutServlet">注销</a>
<br>
<div style="margin:0 auto">
</div>
<div style="margin:0 auto">
<table border="1" cellspacing="0" style="margin:0 auto">
<caption><h3>我的项目表</h3></caption>
<tr>
<td><h3>审核号</h3></td>
<td><h3>项目名</h3></td>
<td><h3>研究员姓名</h3></td>
<td><h3>项目经费</h3></td>
<td><h3>项目启动时间</h3></td>
<td><h3>项目状态</h3></td>
<td><h3>项目结束时间</h3></td>
<td><h3>审核人员</h3></td>
</tr>
<tr>
<td>${datas.check_no }</td>
<td>${datas.rese_name }</td>
<td>${datas.check_projeckname }</td>
<td>${datas.check_projmoney }</td>
<td>${datas.check_start }</td>
<td>${datas.check_status }</td>
<td>${datas.check_end }</td>
<td>${datas.check_name }</td>
</tr>
</table>
</div>
</body>
</html>
SQL部分(这是不同时期做的数据库,数据库功能较多只做了一点点)
CREATE TABLE `gxkygl`.`Untitled` (
`rese_no` char(6) NOT NULL COMMENT '研究人员编号',
`rese_name` char(12) NOT NULL COMMENT '姓名',
`rese_sex` enum('男','女') COMMENT '性别',
`rese_birthday` date COMMENT '出生日期',
`rese_degree` char(4) COMMENT '学位',
`rese_profess` char(12) COMMENT '职称',
`rese_dapart` char(50) COMMENT '部门',
PRIMARY KEY (`rese_no`)
);
CREATE TABLE `aucheck` (
`check_no` char(10) NOT NULL COMMENT '审核号',
`check_reseno` char(6) NOT NULL COMMENT '科研人员编号',
`check_projmoney` int(0) COMMENT '项目经费',
`check_projeckname` char(60) COMMENT '项目名称',
`check_start` date COMMENT '提交时间',
`check_end` date COMMENT '审核时间',
`check_status` enum('审核中','通过','不予通过') COMMENT '审核状态',
`check_name` char(10) COMMENT '审核人',
PRIMARY KEY (`check_no`) USING BTREE,
INDEX `jajf_KEY`(`check_reseno`) USING BTREE,
CONSTRAINT `jajf_KEY` FOREIGN KEY (`check_reseno`) REFERENCES `researchers` (`rese_no`)
);
CREATE TABLE `projeck` (
`projeck_no` char(20) COMMENT '项目编号',
`projeck_name` char(60) COMMENT '项目名称',
`projeck_money` int(0) COMMENT '项目经费',
`projeck_date` date COMMENT '立项时间',
`projeck_status` enum('在研','完成','暂停','撤销','审核中')COMMENT '项目状态',
PRIMARY KEY (`projeck_no`) USING BTREE,
UNIQUE INDEX `index_pro`(`projeck_no`) USING BTREE
);
CREATE TABLE `scirese` (
`projeck_no` char(20) COMMENT '项目编号',
`rese_no` char(6) COMMENT '科研人员编号',
PRIMARY KEY (`projeck_no`, `rese_no`) USING BTREE,
INDEX `rese_KEY`(`rese_no`) USING BTREE,
CONSTRAINT `peojeck_KEY` FOREIGN KEY (`projeck_no`) REFERENCES `projeck` (`projeck_no`),
CONSTRAINT `rese_KEY` FOREIGN KEY (`rese_no`) REFERENCES `researchers` (`rese_no`)
);
CREATE TABLE `paper` (
`paper_no` char(20) NOT NULL COMMENT '论文编号',
`paper_name` char(60) COMMENT '论文名称',
`paper_author` char(6) NOT NULL COMMENT '论文作者编号',
`paper_publish` char(60) COMMENT '出版社',
`paper_qkno` char(20) COMMENT '期刊号',
`paper_date` date COMMENT '出版时间',
PRIMARY KEY (`paper_no`) USING BTREE,
INDEX `jfja_KEY`(`paper_author`) USING BTREE,
CONSTRAINT `jfja_KEY` FOREIGN KEY (`paper_author`) REFERENCES `researchers` (`rese_no`)
);
CREATE TABLE `prizewinner` (
`prizewinner_no` char(20) NOT NULL COMMENT '著作编码',
`prizewinner_name` char(60) COMMENT '著作名称',
`prizewinner_author` char(6) NOT NULL COMMENT '作者编码',
`prizewinner_bookno` char(20) COMMENT '书号',
`prizewinner_publish` char(40) COMMENT '出版社',
`prizewinner_date` date COMMENT '出版时间',
PRIMARY KEY (`prizewinner_no`) USING BTREE,
INDEX `prizewinner_key`(`prizewinner_author`) USING BTREE,
UNIQUE INDEX `index_prize`(`prizewinner_no`) USING BTREE,
CONSTRAINT `prizewinner_key` FOREIGN KEY (`prizewinner_author`) REFERENCES `researchers` (`rese_no`)
);
CREATE TABLE `reward` (
`reward_no` char(20) NOT NULL COMMENT '获奖编号',
`reward_name` char(60) COMMENT '成果名称',
`reward_author` char(6) NOT NULL COMMENT '作者编码',
`reward_rename` char(20) COMMENT '奖励名称',
`reward_degree` enum('特等奖','一等奖','二等奖','三等奖') COMMENT '奖励等级',
`reward_rank` enum('国家级','省部级','市级','校级') COMMENT '奖励级别',
PRIMARY KEY (`reward_no`) USING BTREE,
INDEX `reward`(`reward_author`) USING BTREE,
CONSTRAINT `reward` FOREIGN KEY (`reward_author`) REFERENCES `researchers` (`rese_no`)
);
CREATE TABLE `administrator` (
`admini_no` char(20) NOT NULL COMMENT '管理员账号',
`admini_name` char(10) COMMENT '管理员姓名',
`admini_passwd` char(20) NOT NULL COMMENT '管理员密码'
);
CREATE TABLE `person` (
`person_no` char(10) NOT NULL COMMENT '用户账号',
`person_passwd` char(20) NOT NULL COMMENT '密码',
PRIMARY KEY (`person_no`) USING BTREE
);
--添加缩印
ALTER TABLE `gxkygl`.`paper`
ADD UNIQUE INDEX `index_paper`(`paper_name`);
ALTER TABLE `gxkygl`.`paper`
DROP INDEX `author_key`,
DROP INDEX `index_paper`,
ADD UNIQUE INDEX `author_key`(`paper_author`) USING BTREE,
ADD INDEX `index_paper`(`paper_name`) USING BTREE;
ALTER TABLE `gxkygl`.`researchers`
ADD INDEX `index_rese`(`rese_no`);
ALTER TABLE `gxkygl`.`projeck`
ADD UNIQUE INDEX `index_pro`(`projeck_no`);
CREATE UNIQUE INDEX index_admi ON administrator(admini_no);
CREATE UNIQUE INDEX index_person ON person(person_no);
--查看科研人员研究项目的视图
CREATE VIEW `reseofprojeck` AS SELECT
researchers.rese_no,
researchers.rese_name,
projeck.projeck_no,
projeck.projeck_name,
projeck.projeck_money,
projeck.projeck_date,
projeck.projeck_status
FROM
projeck
INNER JOIN scirese ON projeck.projeck_no = scirese.projeck_no
INNER JOIN researchers ON researchers.rese_no = scirese.rese_no;
--查看科研人员具体获奖信息的视图
CREATE VIEW `reseofreward` AS SELECT
researchers.rese_name,
reward.*
FROM
researchers
INNER JOIN
reward
ON
researchers.rese_no = reward.reward_author;
--查看体检项目审核情况
CREATE VIEW submitprojeckinfo AS SELECT
researchers.rese_no,
researchers.rese_name,
aucheck.check_projmoney,
aucheck.check_projeckname,
aucheck.check_start,
aucheck.check_end,
aucheck.check_status,
aucheck.check_name
FROM
aucheck
INNER JOIN
researchers
ON
aucheck.check_reseno = researchers.rese_no;
--查看科研人员论文情况
CREATE VIEW count_paper AS SELECT
researchers.*,
COUNT(paper.paper_no) AS total_paper
FROM
paper
INNER JOIN
researchers
ON
paper.paper_author = researchers.rese_no
GROUP BY
rese_no;
--查看科研人员著作相关情况
CREATE VIEW count_prizewinner AS SELECT
researchers.*,
COUNT(prizewinner.prizewinner_no) AS total_prizewinner
FROM
prizewinner
INNER JOIN
researchers
ON
prizewinner.prizewinner_author = researchers.rese_no
GROUP BY
rese_no;
--查看科研人员获奖信息
CREATE VIEW jutihuojiang AS SELECT
researchers.*,
COUNT(reward.reward_no) AS total_reward
FROM
reward
INNER JOIN
researchers
ON
reward.reward_author = researchers.rese_no
GROUP BY
rese_no;