后台添加留言管理
This commit is contained in:
parent
aa044b3c03
commit
cb090dc1a2
37
src/com/landaiqing/servlet/system/ListManage.java
Normal file
37
src/com/landaiqing/servlet/system/ListManage.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package com.landaiqing.servlet.system;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.landaiqing.entity.UserEntity;
|
||||||
|
import com.landaiqing.service.UserService;
|
||||||
|
import jakarta.servlet.ServletException;
|
||||||
|
import jakarta.servlet.annotation.WebServlet;
|
||||||
|
import jakarta.servlet.http.HttpServlet;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@WebServlet("/listManage")
|
||||||
|
public class ListManage extends HttpServlet {
|
||||||
|
private UserService userService=new UserService();
|
||||||
|
@Override
|
||||||
|
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
|
doPost(req,resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
|
PrintWriter writer = resp.getWriter();
|
||||||
|
List<UserEntity> userEntities=userService.list();
|
||||||
|
String jsonString = JSONObject.toJSONString(userEntities);
|
||||||
|
writer.println(jsonString);
|
||||||
|
writer.close();
|
||||||
|
// req.setAttribute("listManage",jsonString);
|
||||||
|
// req.getRequestDispatcher("./System/index.jsp").forward(req,resp);
|
||||||
|
}
|
||||||
|
}
|
@ -9,8 +9,66 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Title</title>
|
<title>Title</title>
|
||||||
|
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
|
||||||
|
<!-- 引入 layui.css -->
|
||||||
|
<link href="//unpkg.com/layui@2.8.0/dist/css/layui.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<!-- 引入 layui.js -->
|
||||||
|
<script src="//unpkg.com/layui@2.8.0/dist/layui.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
留言管理
|
<table class="layui-hide" id="ID-table-demo-data"></table>
|
||||||
|
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
|
||||||
|
<script>
|
||||||
|
function getDate(){
|
||||||
|
axios({
|
||||||
|
// 请求方式
|
||||||
|
method: 'get',
|
||||||
|
// 请求的地址
|
||||||
|
url: 'http://localhost:8080${pageContext.request.contextPath}/listManage',
|
||||||
|
// URL 中的查询参数
|
||||||
|
params: {
|
||||||
|
|
||||||
|
}
|
||||||
|
}).then(function (result) {
|
||||||
|
console.log(result);
|
||||||
|
layui.use('table', function(){
|
||||||
|
var table = layui.table;
|
||||||
|
var form = layui.form;
|
||||||
|
var dropdown = layui.dropdown;
|
||||||
|
// 已知数据渲染
|
||||||
|
var inst = table.render({
|
||||||
|
elem: '#ID-table-demo-data'
|
||||||
|
,cols: [[ //标题栏
|
||||||
|
{field: 'userId', title: 'ID', width: 80, sort: true}
|
||||||
|
,{field: 'nickName', title: '昵称', width: 130}
|
||||||
|
,{field: 'qQ', title: 'QQ', width: 130}
|
||||||
|
,{field: 'email', title: '邮箱', width: 180},
|
||||||
|
{field:'content', title: '评论内容', width:250, },
|
||||||
|
{field:'dateTime', title: '评论时间', width:130, },
|
||||||
|
{field:'replyContent', title: '回复内容', width:200, },
|
||||||
|
{field:'replyDateTime', title: '回复时间', width:130, },
|
||||||
|
// {fixed: 'right', title:'操作', width: 134, minWidth: 125, toolbar: '#barDemo'}
|
||||||
|
|
||||||
|
]]
|
||||||
|
,data: result.data
|
||||||
|
//,skin: 'line' // 表格风格
|
||||||
|
//,even: true
|
||||||
|
,page: true // 是否显示分页
|
||||||
|
,limits: [5, 10, 15]
|
||||||
|
,limit: 5 // 每页默认显示的数量
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
getDate();
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user