页面运行失败
相关代码:
package com.imooc.reader.controller.management;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.imooc.reader.entity.Evaluation;
import com.imooc.reader.service.EvaluationService;
import com.imooc.reader.service.exception.BussinessException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping("/management/evaluation")
public class MEvaluationController {
@Resource
private EvaluationService evaluationService;
@GetMapping("/evaluation.html")
public ModelAndView showEvaluation(){
return new ModelAndView("/management/evaluation");
}
@GetMapping("/list")
@ResponseBody
public Map list(Integer page, Integer rows){
Map result=new HashMap();
if(page==null){
page=1;
}
if(rows==null){
rows=20;
}
IPage<Evaluation> evaluationIPage=evaluationService.list(page,rows);
result.put("code","0");
result.put("data",evaluationIPage.getRecords());
result.put("message","");
return result;
}
@PostMapping("/disable")
@ResponseBody
public Map UpdateState(Evaluation evaluation){
Map result=new HashMap();
try {
Evaluation rawEvaluation = evaluationService.updateState(evaluation);
rawEvaluation.setState("disable");
rawEvaluation.setDisableReason(evaluation.getDisableReason());
rawEvaluation.setDisableTime(new Date());
evaluationService.updateState(rawEvaluation);
}catch(BussinessException ex){
ex.printStackTrace();
result.put("code",ex.getCode());
result.put("msg",ex.getMsg());
}
return result;
}
}
相关代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>短评管理</title>
<style>
#dlgBook{
padding: 10px
}
</style>
<link rel="stylesheet" href="/resources/layui/css/layui.css">
</head>
<body>
<div class="layui-container">
<blockquote class="layui-elem-quote">近期短评列表</blockquote>
<table id="grdEvaluation" lay-filter="grdEvaluation"></table>
</div>
<script src="/resources/layui/layui.all.js"></script>
<script>
var table = layui.table;
var $ = layui.$;
var editor = null;
//第一个实例
table.render({
elem: '#grdEvaluation'
, id : "evaluationList"
, url: "/management/evaluation/list" //数据接口
, page: true //开启分页
, limit :20
, cols: [[ //表头
{field:"createTime" , title: '发布时间', width: '200'}
, {field: 'content', title: '短评', width: '400'}
, {type:"space" ,title: '图书', width: '200', templet: function (d) {
return d.book.bookName;
}}
, {type: "space" , title: '用户名', width: '100', templet: function (d) {
console.info(d);
return d.member.username;
}}
, {type: 'space', title: '操作', width: '100' , templet : function(d){
if(d.state=="enable") {
return "<button class='layui-btn layui-btn-sm ' data-id='" + d.evaluationId + "' onclick='disableEvaluation(this)'>禁用</button>";
}else if(d.state =="disable"){
return "已禁用";
}
}
}
]]
});
function disableEvaluation(obj){
var evaluationId = $(obj).data("id");
layui.layer.prompt({
title: '请输入禁用原因',
},function(value, index, elem){
$.post("/management/evaluation/disable" , {
evaluationId : evaluationId , reason:value
},function(json){
if(json.code=="0"){
layui.layer.close(index);
layui.layer.msg("短评已禁用")
table.reload('evaluationList');
}
} , "json")
});
}
</script>
</body>
</html>
相关代码:
package com.imooc.reader.controller.management;
import com.imooc.reader.entity.User;
import com.imooc.reader.service.UserService;
import com.imooc.reader.service.exception.BussinessException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping("/management/user")
public class MUserController {
@Resource
private UserService userService;
@GetMapping("/login.html")
public ModelAndView showLogin(){
return new ModelAndView("/management/login");
}
@PostMapping("/check_login")
@ResponseBody
public Map checklogin(String username,String password,HttpSession session){
Map result=new HashMap();
try {
User user = userService.checklogin(username,password);
session.setAttribute("loginUser",user);
result.put("code", "0");
result.put("msg", "success");
result.put("redirect_url","/management/index.html");
}catch(BussinessException ex){
ex.printStackTrace();
result.put("code",ex.getCode());
result.put("msg",ex.getMsg());
}
return result;
}
}
相关代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>图书管理系统</title>
<link rel="stylesheet" href="/resources/layui/css/layui.css">
<style>
body{
background-color: #F2F2F2;
}
.oa-container{
/*background-color: white;*/
position: absolute;
width: 400px;
height: 350px;
top: 50%;
left: 50%;
padding: 20px;
margin-left: -200px;
margin-top: -175px;
}
#username,#password{
text-align: center;
font-size: 24px;
}
</style>
</head>
<body>
<div class="oa-container">
<h1 style="text-align: center;margin-bottom: 20px">图书管理系统</h1>
<form class="layui-form">
<div class="layui-form-item">
<input type="text" id="username" lay-verify="required" name="username" placeholder="请输入用户名" autocomplete="off" class="layui-input" >
</div>
<div class="layui-form-item">
<input type="password" id="password" lay-verify="required" name="password" placeholder="请输入密码" autocomplete="off" class="layui-input" >
</div>
<div class="layui-form-item">
<button class="layui-btn layui-btn-fluid" lay-submit lay-filter="login">登录</button>
</div>
</form>
</div>
<script src="/resources/layui/layui.all.js"></script>
<script>
// 表单提交事件
layui.form.on("submit(login)" , function(formdata){//data参数包含了当前表单的数据
console.log(formdata);
//发送ajax请求进行登录校验
layui.$.ajax({
url : "/management/user/check_login",
data : formdata.field, //提交表单数据
type : "post",
dataType : "json" ,
success : function(json){
console.log(json);
if(json.code == "0"){ //登录校验成功
//layui.layer.msg("登录成功");
//跳转url
window.location.href=json.redirect_url;
}else{
layui.layer.msg(json.message);
}
}
})
return false;//submit提交事件返回true则表单提交,false则阻止表单提交
})
</script>
</body>
</html>
17
收起
正在回答 回答被采纳积分+1
java工程师2020版
- 参与学习 人
- 提交作业 9393 份
- 解答问题 16556 个
综合就业常年第一,编程排行常年霸榜,无需脱产即可学习,北上广深月薪过万 无论你是未就业的学生还是想转行的在职人员,不需要基础,只要你有梦想,想高薪
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星