“七十三” 2023-02-24 20:46 采纳率: 44.4%
浏览 24
已结题

网站报错500,用的IDEA测试的

IDEA,报错500


<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta charset="utf-8"/>
    <title>ford-用户登录</title>
    <base href="http://localhost:8080/BWCFdatabase/">
    <link ) rel="shortcut icon" href="favicon.ico" type="http://localhost:8080/BWCFdatabase/image/vnd.microsoft.icon">
    <link ) rel="icon" href="theme.ico" type="image/vnd.microsoft.icon">
    <link rel="stylesheet" href="http://localhost:8080/BWCFdatabase/assets/libs/layui/css/layui.css?20221225140425" />
    <link rel="stylesheet" href="http://localhost:8080/BWCFdatabase/assets/css/login.css?20221225140425" media="all">
    <link rel="stylesheet" href="http://localhost:8080/BWCFdatabase/assets/css/foxnic-web.css?20221225140425">
    <link rel="stylesheet" href="http://localhost:8080/BWCFdatabase/console/pear/component/pear/css/pear-support.css?20221225140425">
    <script>var foxnic_cachekey="20221225140425";</script>
    <style>
        #login-panel {
            width: 300px;
            border-radius: 16px;
            position: absolute;
            background-color: #fff;
            left: 100px;
            top: 100px;
            box-shadow: 0px 0px 4px 4px rgba(0, 0, 0, .15);
            display: flex;
            flex-direction: column;
            align-content: center;
            align-items: center;
            padding-top: 20px;
            opacity:0.0;
        }
        .logo {
            width: 80px;
            height: auto;
        }
        .title {
            margin-top: 16px;
            margin-bottom: 8px;
            font-weight: 700;
            font-size: 15px;
            color: #444;
        }
        .tool-button {
            width: 40px;
            height: 40px;
            padding: 2px;
            font-size: 18px;
            cursor: pointer;
            background: #FFF;
            text-align: center;
            line-height: 40px;
            margin-bottom: 0px;
            border-radius: 50%;
            position: absolute;
            color: #acacac;
            right: 24px;
            bottom: 28px;
            display: block;
            -webkit-box-shadow: 0px 1px 20px 0px rgb(0 0 0 / 10%), inset 0px -1px 0px 0px rgb(0 0 0 / 10%);
            box-shadow: 0px 1px 20px 0px rgb(0 0 0 / 10%), inset 0px -1px 0px 0px rgb(0 0 0 / 10%);
        }
        .lang-icon {
            font-size: 24px;
        }
        .lang-icon:hover {
            font-size: 24px;
            color: #333;
        }
        span{
            color: red;
        }
    </style>
</head>

<body style="background-image:url(http://localhost:8080/BWCFdatabase/assets/images/bg_login_2.png);background-repeat:no-repeat;background-size:cover;">

<div class="login-body">
    <div id="login-panel" class="layui-form-pane">
        <img class="logo" src="http://localhost:8080/BWCFdatabase/assets/images/foxnic.png">
        <div class="title">百旺长福数据中心</div>

        <form action="http://localhost:8080/BWCFdatabase/registServlet" method="post">
            <div class="layui-form-item">
                <label class="layui-form-label"><i class="layui-icon layui-icon-username"></i></label>
                <div class="layui-input-block">
                    <input name="username" type="text" lay-verify="required" placeholder="账号" value=""
                           class="layui-input">
                    <%
                    String loginMsg = (String)request.getAttribute("login_msg");
                    %>
                    <span ><%=loginMsg %></span>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><i class="layui-icon layui-icon-password"></i></label>
                <div class="layui-input-block">
                    <input name="password" type="password" lay-verify="required" placeholder="密码" value=""
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <button lay-filter="login-submit" id="login-submit" class="layui-btn layui-btn-fluid" style="background-color: #f56c6c;" lay-submit>登 录</button>
            </div>
        </form>

    </div>
</div>

<div class="login-footer" style="background-color: rgb(0,0,0,0.0);height: 32px;padding-bottom: 0px">
    <p><a  target="_blank">百旺长福数据中心</a></p>
</div>

<div class="tool-button foxnic-lang">
    <i class="layui-icon layui-icon-website lang-icon" update-text="0"></i>
</div>

<script type="text/javascript" src="http://localhost:8080/BWCFdatabase/module/global.js?20221225140425"></script>
<script type="text/javascript" src="http://localhost:8080/BWCFdatabase/assets/libs/layui/layui.js?20221225140425"></script>
<script type="text/javascript" src="http://localhost:8080/BWCFdatabase/module/Math.uuid.js?20221225140425"></script>

<script>
    var LANGUAGES = [{"code":"auto","property":"auto","text":"\u81EA\u52A8\u8BC6\u522B"},{"code":"defaults","property":"defaults","text":"\u9ED8\u8BA4\u8BED\u8A00"},{"code":"zh_cn","property":"zhCn","text":"\u4E2D\u6587\u7B80\u4F53"},{"code":"zh_tw","property":"zhTw","text":"\u4E2D\u6587(\u53F0\u6E7E)"},{"code":"zh_hk","property":"zhHk","text":"\u4E2D\u6587(\u9999\u6E2F)"},{"code":"zh_mo","property":"zhMo","text":"\u4E2D\u6587(\u6FB3\u95E8)"},{"code":"en_us","property":"enUs","text":"English-US"},{"code":"en_gb","property":"enGb","text":"English-UK"},{"code":"ko_kr","property":"koKr","text":"\uD55C\uAD6D\uC5B4"},{"code":"ja_jp","property":"jaJp","text":"\u65E5\u672C\u8A9E"},{"code":"confuse","property":"confuse","text":"\u6DF7\u6DC6"}];
    var USER_LANGUAGE_PROP="zhCn";
    var USER_LANGUAGE_CODE="zh_cn";
    var LANGUAGE_RANGE = ["defaults","auto","zh_cn","en_gb","zh_tw"];
</script>
<script>
    localStorage.setItem("theme","PEAR");
    if(window!=top) top.location="/login.html"
    layui.config({
        base: 'http://localhost:8080/BWCFdatabase/module/'
    }).use(['form','settings','dropdown'], function () {
        let $ = layui.jquery;
        function updatePosition() {
            var fullHeight = $(window).height();
            var fullWidth = $(window).width();
            var formHeight = $("#login-panel").height();
            var formWidth = $("#login-panel").width();
            var formTop = (fullHeight - formHeight) * 0.4;
            var formLeft = (fullWidth - formWidth) / 2;
            $("#login-panel").css("top", formTop + "px");
            $("#login-panel").css("left", formLeft + "px");
            console.log("resize:"+formTop+","+formLeft);
        }
        updatePosition();
        $("#login-panel").css("display","");
        setTimeout(function (){
            $("#login-panel").animate({
                opacity:'1.0'
            },1000);
        },16)

        $(window).on('resize', updatePosition);
        //debugger
    });

</script>
<script type="text/javascript" src="http://localhost:8080/BWCFdatabase/login.js?20221225140425"></script>
</body>
</html>



HTTP状态 500 - 内部服务器错误
类型 异常报告

描述 服务器遇到一个意外的情况,阻止它完成请求。

例外情况

java.lang.NullPointerException
    com.bwcf.web.RegistServlet.doPost(RegistServlet.java:33)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:682)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:765)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
):注意 主要问题的全部 stack 信息可以在 server logs 里查看

Apache Tomcat/8.5.85

package com.bwcf.web;

import com.bwcf.pojo.User;
import com.bwcf.service.UserService;
import com.bwcf.service.impl.UserServiceImpl;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class RegistServlet extends HttpServlet {

    private UserService userService = new UserServiceImpl();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取请求的参数
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        //调用userService.login()登录处理业务
        User loginUser = userService.login(new User(null, username, password, null));
        //如果等于null说明登录失败
        if (loginUser == null){
            // 跳回登录界面
            req.setAttribute("login_msg", "账户或密码不正确");
            RequestDispatcher rd = req.getRequestDispatcher("index.jsp");
            rd.forward(req,resp);
        } else {
            //登录成功
            req.getRequestDispatcher("../web/pages/index11.jsp").forward(req,resp);

        }
    }
}


img

  • 写回答

1条回答 默认 最新

  • pzzhao 2023-02-24 21:04
    关注

    空指针异常,看下 RegistServlet 的第33行

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 3月6日
  • 已采纳回答 2月26日
  • 创建了问题 2月24日

悬赏问题

  • ¥100 谁能在荣耀自带系统MagicOS版本下,隐藏手机桌面图标?
  • ¥15 求SC-LIWC词典!
  • ¥20 有关esp8266连接阿里云
  • ¥15 C# 调用Bartender打印机打印
  • ¥15 我这个代码哪里有问题 acm 平台上显示错误 90%,我自己运行好像没什么问题
  • ¥50 C#编程中使用printDocument类实现文字排版打印问题
  • ¥15 找会编程的帅哥美女 可以用MATLAB里面的simulink编程,用Keil5编也可以。
  • ¥15 已知隐函数其中一个变量τ的具体值,求另一个变量
  • ¥15 r语言Hurst指数
  • ¥15 RT-Thread Studio编译问题