You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
test/userDetail.jsp

286 lines
9.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<<<<<<< HEAD
package com.itbaizhan.action;
import java.io.IOException;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.itbaizhan.dao.DB;
import com.itbaizhan.orm.Tuser;
import com.itbaizhan.service.liuService;
public class user_servlet extends HttpServlet
{
public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
String type = req.getParameter("type");
if(type.endsWith("userReg"))
{
userReg(req, res);
}
if(type.endsWith("userLogout"))
{
userLogout(req, res);
}
if(type.endsWith("userMana"))
{
userMana(req, res);
}
if(type.endsWith("userDel"))
{
userDel(req, res);
}
if(type.endsWith("userDetail"))
{
userDetail(req, res);
}
}
public void userReg(HttpServletRequest req, HttpServletResponse res)
{
String id = String.valueOf(new Date().getTime());
String loginname = req.getParameter("loginname");
String loginpw = req.getParameter("loginpw");
String name = req.getParameter("name");
String del = "no";
String s = liuService.panduan_zhanghao(loginname);
if(s.equals("yizhan"))
{
req.setAttribute("message", "账号已占用,请重新选择账号");
req.setAttribute("path", "site/userreg/userreg.jsp");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
else
{
String sql = "insert into t_user values(?,?,?,?,?)";
Object[] params = {id, loginname, loginpw, name, del};
DB mydb = new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("message", "注册成功,请登录");
req.setAttribute("path", "site/default.jsp");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
}
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()
{
}
}
=======
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ page isELIgnored="false" %>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
<meta http-equiv="description" content="This is my page" />
<link rel="stylesheet" type="text/css" href="<%=path %>/css/base.css" />
<script language="JavaScript" src="<%=path %>/js/public.js" type="text/javascript"></script>
<script language="javascript">
function xinyongAdd(user_id) //添加用户信用评价模块
{ //引入外部js文件增加页面的整洁性和代码的可维护性
var url="<%=path %>/admin/xinyong/xinyongAdd.jsp?user_id="+user_id;
window.location.href=url; //跳转到用户id的xinyongAdd.jsp界面
}
</script>
</head>
<body leftmargin="2" topmargin="2" background='<%=path %>/img/allbg.gif'>
<table width="98%" border="0" cellpadding="2" cellspacing="1" bgcolor="#D1DDAA" align="center" style="margin-top:8px">
<tr bgcolor="#E7E7E7">
<td height="14" colspan="14" background="<%=path %>/img/tbg.gif">&nbsp;&nbsp;</td>
</tr>
<tr align="center" bgcolor="#FAFAF1" height="22">
<td width="4%">序号</td>
<td width="10%">账号</td>
<td width="10%">密 码</td>
<td width="10%">姓名</td>
<td width="10%">操作</td>
</tr>
<c:forEach items="${requestScope.userList}" var="user" varStatus="ss"> <!-- 获取用户信息输出序号初值为1 -->
<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='red';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
<td bgcolor="#FFFFFF" align="center">
${ss.index+1}<!--设置序号从1开始 -->
</td>
<td bgcolor="#FFFFFF" align="center">
${user.loginname}
</td>
<td bgcolor="#FFFFFF" align="center">
${user.loginpw}
</td>
<td bgcolor="#FFFFFF" align="center">
${user.name} <!-- 取得用户的各种信息 -->
</td>
<td bgcolor="#FFFFFF" align="center">
<input type="button" value="添加信用评价" onclick="xinyongAdd(${user.id})"/> <!-- 触发添加信用jsp文件 -->
</td>
</tr>
</c:forEach>
</table>
<c:forEach items="${requestScope.xinyongList}" var="xinyong" varStatus="sta">
&nbsp;&nbsp;&nbsp;
<fieldset style="width:60%; margin-left:5px;"><legend class="fieldtitle"></legend> <!-- 使用fieldset来为这几条加上框 -->
<table class="bill" width="97%" cellpadding="4" cellspacing="4" border="0">
<tr>
<td style="width: 100">属性:${xinyong.shuxing}</td>
</tr>
<tr>
<td style="width: 100">评价内容:${xinyong.neirong}</td>
</tr>
<tr>
<td style="width: 100">评价时间:${xinyong.shijian}</td>
</tr>
</table>
</fieldset>
<br/>
</c:forEach>
</body>
</html>
>>>>>>> remotes/origin/wyp_branch