Failed to load resources: net:: ERR_CONNECTION_REFUSED
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | <!DOCTYPE html> < html > < head > < meta charset = "UTF-8" > < title >imooc办公OA系统</ title > < link rel = "stylesheet" href = "/resources/layui/css/layui.css" > < style > body { background-color: #f2f2f2; } .oa-container{ /*background-color: #FFF;*/ position: absolute; width: 400px; height: 350px; top:50%; left:50%; padding:20px; margin-left:-200px; margin-top: -175px; } .oa-container .headline{ text-align: center; margin-bottom: 20px; } #username,#password{ text-align: center; font-size:24px; } </ style > </ head > < body > < div class = "oa-container" > < h1 class = "headline" >慕课网OA办公系统</ h1 > < form class = "layui-form" > < div class = "layui-form-item" > < input class = "layui-input" type = "text" id = "username" lay-verify = "required" name = "username" placeholder = "请输入用户名" autocomplete = "off" > </ div > < div class = "layui-form-item" > < input class = "layui-input" type = "password" id = "password" lay-verify = "required" name = "password" placeholder = "请输入密码" autocomplete = "off" > </ 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 (data) { //data包含了当前表单的数据 console.log(data); layui.$.ajax({ url : "/check_login", data: data.field, //data.field包含当前页面的数据 type: "post", dataType:"json", success:function (json){ console.log(json) if(json.code == "0"){ window.location.href = json.redirect_url; }else { layui.layer.msg(json.message); } } }) return false; //subimit事件 if return true则会提交表单 }) </ script > </ body > </ html > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | package com.imooc.oa.controller; //接收了来自界面的用户输入,以及调用业务逻辑并且返回结果 import com.alibaba.fastjson.JSON; import com.imooc.oa.entity.User; import com.imooc.oa.service.UserService; import com.imooc.oa.service.exception.BussinessException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.annotation.*; import java.io.IOException; import java.util.HashMap; import java.util.Map; @WebServlet (name = "LoginServlet" , value = "/check_login" ) public class LoginServlet extends HttpServlet { Logger logger = LoggerFactory.getLogger(LoginServlet. class ); private UserService userService = new UserService(); // 登录校验包含用户名和密码等敏感数据,所以需要通过Post请求来提交数据 @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding( "utf-8" ); response.setContentType( "text/html;charset=utf-8" ); String username = request.getParameter( "username" ); String password = request.getParameter( "password" ); Map<String,Object> result = new HashMap<>(); try { //调用业务逻辑 User user = new UserService().checkLogin(username, password); HttpSession session = request.getSession(); session.setAttribute( "login_user" ,user); result.put( "code" , "0" ); result.put( "message" , "success" ); result.put( "redirect_url" , "/index" ); } catch (BussinessException e) { logger.error(e.getMessage(),e); result.put( "code" ,e.getCode()); result.put( "message" , e.getMessage()); } catch (Exception e) { logger.error(e.getMessage(),e); result.put( "code" ,e.getClass().getSimpleName()); result.put( "message" , e.getMessage()); } //return the result String json = JSON.toJSONString(result); response.getWriter().println(json); } @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } } |
问题描述:
之前没有这个问题,今天开机突然出现了
28
收起
正在回答
2回答
同学你好,根据上传截图可知,代码报错信息为NoClassDefFoundError:无法初始化MybatisUtils类。
NoClassDefFoundError异常表示是在运行时JVM加载不到类或者找不到类。在初始化的时候,加载了配置文件mybatis-config.xml,那么很有可能是配置文件的问题,建议同学检查mybatis-config.xml以及dao对应的xml映射文件中是否有拼写等错误。
1)检查下mybatis-config.xml中的mapper文件名与项目中的文件名是否一致,若不一致则进行修改。例如:
2)再检查下mapper文件中是否存在同名的id
3)检查下parameterType中包名、类名是否正确
4)若不存在上述问题则建议将代码上传至问答区,老师测试后再给予解答。
祝学习愉快~
java工程师2020版
- 参与学习 人
- 提交作业 9404 份
- 解答问题 16556 个
综合就业常年第一,编程排行常年霸榜,无需脱产即可学习,北上广深月薪过万 无论你是未就业的学生还是想转行的在职人员,不需要基础,只要你有梦想,想高薪
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧