Merge remote-tracking branch 'remotes/origin/develop' into wlk_branch

wlk_branch
IE-WEB 8 months ago
commit 1d857c9459

@ -0,0 +1 @@
Subproject commit 7ef20de6fbfb1a60e420462747344546a2e84615

@ -1,91 +1,199 @@
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ 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" %>
package com.itbaizhan.action;
<%
String path = request.getContextPath(); // 获取当前Web应用的根路径
%>
import java.io.IOException;
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">
<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" /> <!-- 页面描述 -->
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;
<!-- 引入CSS文件 -->
<link rel="stylesheet" type="text/css" href="<%=path %>/css/base.css" />
<!-- 引入公共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>
import com.itbaizhan.dao.DB;
import com.itbaizhan.orm.Tuser;
import com.itbaizhan.service.liuService;
<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">
<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})"/>
</td>
</tr>
</c:forEach>
</table>
<!-- 遍历信用评价列表,显示评价内容 -->
<c:forEach items="${requestScope.xinyongList}" var="xinyong" varStatus="sta">
&nbsp;&nbsp;&nbsp;
<!-- 使用fieldset为每条信用评价加上框 -->
<fieldset style="width:60%; margin-left:5px;"><legend class="fieldtitle"></legend>
<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>
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()
{
}
}

@ -3,7 +3,7 @@
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ page isELIgnored="false" %>
<%
String path = request.getContextPath();
String path = request.getContextPath(); // 获取应用的上下文路径
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@ -15,16 +15,21 @@ String path = request.getContextPath();
<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" />
<!-- 引入公共 JavaScript 文件 -->
<script language="JavaScript" src="<%=path %>/js/public.js" type="text/javascript"></script>
<!-- 用户删除操作的 JavaScript 函数 -->
<script language="javascript">
function userDel(id)
{
// 弹出确认框,确认是否删除
if(confirm('您确定删除吗?'))
{
window.location.href="<%=path %>/user?type=userDel&id="+id; //如果确认删除,则会跳转到这个界面,?后为传入的参数,提示用户信息删除完毕
// 如果确认删除,跳转到对应的删除页面,并传递用户 ID
window.location.href="<%=path %>/user?type=userDel&id="+id;
}
}
</script>
@ -36,28 +41,32 @@ String path = request.getContextPath();
<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>
<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">
<!-- 循环遍历用户列表,展示用户信息 -->
<c:forEach items="${requestScope.userList}" var="user" varStatus="ss">
<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}
${ss.index+1} <!-- 设置序号,从 1 开始 -->
</td>
<td bgcolor="#FFFFFF" align="center">
${user.loginname}
${user.loginname} <!-- 显示用户账号 -->
</td>
<td bgcolor="#FFFFFF" align="center">
${user.loginpw}
${user.loginpw} <!-- 显示用户密码 -->
</td>
<td bgcolor="#FFFFFF" align="center">
${user.name}
${user.name} <!-- 显示用户姓名 -->
</td>
<td bgcolor="#FFFFFF" align="center">
<input type="button" value="删除" onclick="userDel(${user.id})"/> <!-- 删除时删除主键用户ID完成对整个数据项的删除 -->
<!-- 删除按钮,点击后会调用 userDel 函数 -->
<input type="button" value="删除" onclick="userDel(${user.id})"/>
</td>
</tr>
</c:forEach>

@ -0,0 +1,89 @@
<%@page import="java.text.SimpleDateFormat"%> <!-- 引入 SimpleDateFormat 用于格式化日期 -->
<%@page import="java.util.Date"%> <!-- 引入 Date 类用于获取当前日期和时间 -->
<%@ page language="java" pageEncoding="UTF-8"%> <!-- 设置页面的语言为 Java 和字符编码为 UTF-8 -->
<%@ 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"%> <!-- 启用表达式语言 (EL) -->
<%
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"> <!-- 定义 HTML 文档的 XML 命名空间 -->
<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" />
<!-- 定义 JavaScript 函数,用于验证表单内容 -->
<script language="javascript">
function c()
{
// 如果评价内容为空,弹出提示框
if(document.formAdd.neirong.value=="")
{
alert("请输入评价内容");
return false; // 阻止表单提交
}
document.formAdd.submit(); // 提交表单
}
</script>
</head>
<body leftmargin="2" topmargin="9" background='<%=path %>/img/allbg.gif'> <!-- 设置页面背景 -->
<form action="<%=path %>/xinyong?type=xinyongAdd" name="formAdd" method="post"> <!-- 表单提交地址和方法 -->
<table width="98%" border="0" cellpadding="2" cellspacing="1" bgcolor="#D1DDAA" align="center" style="margin-top:8px">
<tr bgcolor="#E7E7E7">
<td height="14" colspan="4" background="<%=path %>/img/tbg.gif">&nbsp;&nbsp;</td>
</tr>
<!-- 评价属性选择 -->
<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='red';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
<td width="10%" bgcolor="#FFFFFF" align="right">
评价属性:
</td>
<td width="90%" bgcolor="#FFFFFF" align="left">
<!-- 评价属性的选择按钮 -->
<input type="radio" name="shuxing" value="好评" checked="checked" style="border: 0px;"/>好评
&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="shuxing" value="差评" style="border: 0px;"/>差评
</td>
</tr>
<!-- 评价内容输入框 -->
<tr align='center' bgcolor="#FFFFFF" height="22">
<td width="10%" bgcolor="#FFFFFF" align="right">
评价内容:
</td>
<td width="90%" bgcolor="#FFFFFF" align="left">
<input type="text" name="neirong" size="40"/> <!-- 用户输入评价内容 -->
</td>
</tr>
<!-- 自动填写当前时间 -->
<tr align='center' bgcolor="#FFFFFF" height="22">
<td width="10%" bgcolor="#FFFFFF" align="right">
评价时间:
</td>
<td width="90%" bgcolor="#FFFFFF" align="left">
<input type="text" name="shijian" size="40" value="<%=new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date())%>"/> <!-- 使用 SimpleDateFormat 获取当前日期和时间 -->
</td>
</tr>
<!-- 隐藏用户ID和表单操作按钮 -->
<tr align='center' bgcolor="#FFFFFF" height="22">
<td width="10%" bgcolor="#FFFFFF" align="right">
&nbsp;
</td>
<td width="90%" bgcolor="#FFFFFF" align="left">
<input type="hidden" name="user_id" value="<%=request.getParameter("user_id") %>"/> <!-- 获取传入的 user_id -->
<input type="reset" value="重置"/>&nbsp; <!-- 重置按钮 -->
</td>
</tr>
</table>
</form>
</body>
</html>
Loading…
Cancel
Save