Article directory
foreword
Today, seniors share with you a java web project:
Design and Implementation of Project Management System Based on Java EE Platform
Project acquisition:
https://gitee.com/sinonfin/L-javaWebSha
1. Project design
1. Modular design
From an administrator's point of view:
After the user logs in to the system, he can modify the password of the administrator. At the same time, it has the following functions:
1. The administrator can manage specific project information.
2. Administrators can manage project funding information.
3. Administrators can manage project resource information.
4. Administrators can manage project progress information.
5. The administrator can manage the project result information.
From an employee perspective:
Employees can register, and then manage passwords and information. At the same time, it also has the following functions:
1. Employees can view specific project information
2. Employees can view specific funding information
3. Employees can view specific resource information
4. Employees can view specific progress information
5. Employees can view specific achievement information
2. Realize the effect
2. Part of the source code
Some code examples:
判断管理员身份的部分代码:
public String login(String userName,String userPw,int userType)
{
String result="no";
if(userType==0)//系统管理员登陆
{
String sql="select * from t_admin where userName=? and userPw=?";
Object[] params={
userName,userPw};
DB mydb=new DB();
mydb.doPstm(sql, params);
try
{
ResultSet rs=mydb.getRs();
boolean mark=(rs==null||!rs.next()?false:true);
if(mark==false)
{
result="no";
}
else
{
result="yes";
TAdmin admin=new TAdmin();
admin.setUserId(rs.getInt("userId"));
admin.setUserName(rs.getString("userName"));
admin.setUserPw(rs.getString("userPw"));
WebContext ctx = WebContextFactory.get();
HttpSession session=ctx.getSession();
session.setAttribute("userType", 0);
session.setAttribute("admin", admin);
}
rs.close();
}
catch (SQLException e)
{
System.out.println("登录失败!");
e.printStackTrace();
}
finally
{
mydb.closed();
}
}
return result;
}
xiangmu_servlet类,该类的主要功能是与数据库交互,查询或保存企业项目信息,并通过request跳转,打开相应的jsp页面。部分代码是:
public void xiangmuDel(HttpServletRequest req,HttpServletResponse res)
{
String id=req.getParameter("id");
String sql="update t_xiangmu set del='yes' where id=?";
Object[] params={
id};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("message", "操作成功");
req.setAttribute("path", "xiangmu?type=xiangmuMana");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
public void xiangmuMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
String sql="select * from t_xiangmu where del='no'";
req.setAttribute("xiangmuList", getxiangmuList(sql));
req.getRequestDispatcher("admin/xiangmu/xiangmuMana.jsp").forward(req, res);
}
public void xiangmuSele(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
String sql="select * from t_xiangmu where del='no'";
req.setAttribute("xiangmuList", getxiangmuList(sql));
req.getRequestDispatcher("admin/xiangmu/xiangmuSele.jsp").forward(req, res);
}
private List getxiangmuList(String sql){
List xiangmuList=new ArrayList();
Object[] params={
};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
TXiangmu xiangmu=new TXiangmu();
xiangmu.setId(rs.getInt("id"));
xiangmu.setMingcheng(rs.getString("mingcheng"));
xiangmu.setShijian(rs.getString("shijian"));
xiangmu.setFuzeren(rs.getString("fuzeren"));
xiangmuList.add(xiangmu);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
return xiangmuList;
}
Project source code
Project acquisition:
https://gitee.com/sinonfin/L-javaWebSha