wlk_branch^2
IE-WEB 8 months ago
parent c7de4c1d5c
commit 4ffbdd3585

@ -1,91 +1,199 @@
<%@ page language="java" pageEncoding="UTF-8"%> package com.itbaizhan.action;
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <!-- 引入JSTL核心标签库 -->
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> <!-- 引入JSTL格式化标签库 -->
<%@ page isELIgnored="false" %>
<% import java.io.IOException;
String path = request.getContextPath(); // 获取当前Web应用的根路径 import java.sql.ResultSet;
%> import java.util.ArrayList;
import java.util.Date;
import java.util.List;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> import javax.servlet.RequestDispatcher;
<html xmlns="http://www.w3.org/1999/xhtml"> import javax.servlet.ServletConfig;
<head> import javax.servlet.ServletException;
<meta http-equiv="pragma" content="no-cache" /> <!-- 禁用页面缓存 --> import javax.servlet.http.HttpServlet;
<meta http-equiv="cache-control" content="no-cache" /> <!-- 禁用页面缓存 --> import javax.servlet.http.HttpServletRequest;
<meta http-equiv="expires" content="0" /> <!-- 禁用页面缓存 --> import javax.servlet.http.HttpServletResponse;
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" /> <!-- 页面关键字 --> import javax.servlet.http.HttpSession;
<meta http-equiv="description" content="This is my page" /> <!-- 页面描述 -->
<!-- 引入CSS文件 --> import com.itbaizhan.dao.DB;
<link rel="stylesheet" type="text/css" href="<%=path %>/css/base.css" /> import com.itbaizhan.orm.Tuser;
import com.itbaizhan.service.liuService;
<!-- 引入公共JavaScript文件 -->
<script language="JavaScript" src="<%=path %>/js/public.js" type="text/javascript"></script>
<script language="javascript">
// 添加用户信用评价的功能
function xinyongAdd(user_id) {
var url="<%=path %>/admin/xinyong/xinyongAdd.jsp?user_id="+user_id; // 构造跳转链接包含用户ID
window.location.href=url; // 跳转到用户信用评价页面
}
</script>
</head>
<body leftmargin="2" topmargin="2" background='<%=path %>/img/allbg.gif'> public class user_servlet extends HttpServlet
<!-- 用户列表表格 --> {
<table width="98%" border="0" cellpadding="2" cellspacing="1" bgcolor="#D1DDAA" align="center" style="margin-top:8px"> public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
<tr bgcolor="#E7E7E7"> {
<td height="14" colspan="14" background="<%=path %>/img/tbg.gif">&nbsp;&nbsp;</td> <!-- 页眉 --> String type = req.getParameter("type");
</tr>
<tr align="center" bgcolor="#FAFAF1" height="22"> if(type.endsWith("userReg"))
<td width="4%">序号</td> <!-- 序号列 --> {
<td width="10%">账号</td> <!-- 账号列 --> userReg(req, res);
<td width="10%">密 码</td> <!-- 密码列 --> }
<td width="10%">姓名</td> <!-- 姓名列 --> if(type.endsWith("userLogout"))
<td width="10%">操作</td> <!-- 操作列 --> {
</tr> userLogout(req, res);
<!-- 遍历用户列表,显示用户信息 --> }
<c:forEach items="${requestScope.userList}" var="user" varStatus="ss"> if(type.endsWith("userMana"))
<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='red';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22"> {
<td bgcolor="#FFFFFF" align="center"> userMana(req, res);
${ss.index+1} <!-- 设置序号索引从1开始 --> }
</td> if(type.endsWith("userDel"))
<td bgcolor="#FFFFFF" align="center"> {
${user.loginname} <!-- 显示用户账号 --> userDel(req, res);
</td> }
<td bgcolor="#FFFFFF" align="center">
${user.loginpw} <!-- 显示用户密码 --> if(type.endsWith("userDetail"))
</td> {
<td bgcolor="#FFFFFF" align="center"> userDetail(req, res);
${user.name} <!-- 显示用户姓名 --> }
</td> }
<td bgcolor="#FFFFFF" align="center">
<!-- 点击按钮跳转到添加信用评价页面 --> public void userReg(HttpServletRequest req, HttpServletResponse res)
<input type="button" value="添加信用评价" onclick="xinyongAdd(${user.id})"/> {
</td> String id = String.valueOf(new Date().getTime());
</tr> String loginname = req.getParameter("loginname");
</c:forEach> String loginpw = req.getParameter("loginpw");
</table> String name = req.getParameter("name");
String del = "no";
<!-- 遍历信用评价列表,显示评价内容 --> String s = liuService.panduan_zhanghao(loginname);
<c:forEach items="${requestScope.xinyongList}" var="xinyong" varStatus="sta"> if(s.equals("yizhan"))
&nbsp;&nbsp;&nbsp; {
<!-- 使用fieldset为每条信用评价加上框 --> req.setAttribute("message", "账号已占用,请重新选择账号");
<fieldset style="width:60%; margin-left:5px;"><legend class="fieldtitle"></legend> req.setAttribute("path", "site/userreg/userreg.jsp");
<table class="bill" width="97%" cellpadding="4" cellspacing="4" border="0"> String targetURL = "/common/success.jsp";
<tr> dispatch(targetURL, req, res);
<td style="width: 100">属性:${xinyong.shuxing}</td> <!-- 显示信用评价属性 --> }
</tr> else
<tr> {
<td style="width: 100">评价内容:${xinyong.neirong}</td> <!-- 显示评价内容 --> String sql = "insert into t_user values(?,?,?,?,?)";
</tr> Object[] params = {id, loginname, loginpw, name, del};
<tr> DB mydb = new DB();
<td style="width: 100">评价时间:${xinyong.shijian}</td> <!-- 显示评价时间 --> mydb.doPstm(sql, params);
</tr> mydb.closed();
</table>
</fieldset> req.setAttribute("message", "注册成功,请登录");
<br/> req.setAttribute("path", "site/default.jsp");
</c:forEach> String targetURL = "/common/success.jsp";
</body> dispatch(targetURL, req, res);
</html> }
}
public void userLogout(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
HttpSession session = req.getSession();
session.setAttribute("userType", null);
session.setAttribute("user", null);
req.setAttribute("message", "成功退出系统");
req.setAttribute("path", "site/default.jsp");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
public void userMana(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
List userList = new ArrayList();
String sql = "select * from t_user where del='no'";
Object[] params = {};
DB mydb = new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs = mydb.getRs();
while(rs.next())
{
Tuser user = new Tuser();
user.setId(rs.getString("id"));
user.setLoginname(rs.getString("loginname"));
user.setLoginpw(rs.getString("loginpw"));
user.setLoginpw(rs.getString("loginpw"));
user.setName(rs.getString("name"));
userList.add(user);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
req.setAttribute("userList", userList);
req.getRequestDispatcher("admin/user/userMana.jsp").forward(req, res);
}
public void userDel(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
String id = req.getParameter("id");
String sql = "update t_user set del='yes' where id=?";
Object[] params = {id};
DB mydb = new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("msg", "用户信息删除成功");
String targetURL = "/common/msg.jsp";
dispatch(targetURL, req, res);
}
public void userDetail(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
String id = req.getParameter("id");
List userList = new ArrayList();
String sql = "select * from t_user where id=?";
Object[] params = {id};
DB mydb = new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs = mydb.getRs();
while(rs.next())
{
Tuser user = new Tuser();
user.setId(rs.getString("id"));
user.setLoginname(rs.getString("loginname"));
user.setLoginpw(rs.getString("loginpw"));
user.setLoginpw(rs.getString("loginpw"));
user.setName(rs.getString("name"));
userList.add(user);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
req.setAttribute("userList", userList);
req.setAttribute("xinyongList", liuService.getxinyongList(id));
req.getRequestDispatcher("admin/user/userDetail.jsp").forward(req, res);
}
public void dispatch(String targetURI, HttpServletRequest request, HttpServletResponse response)
{
RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
try
{
dispatch.forward(request, response);
}
catch (ServletException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void destroy()
{
}
}

Loading…
Cancel
Save