我是靠谱客的博主 清新小伙,这篇文章主要介绍类型 异常报告 消息 null 描述 服务器遇到一个意外的情况,阻止它完成请求。 例外情况 java.lang.NumberFormatException: null java.base/,现在分享给大家,希望可以做个参考。

在idea上面写 在servlet里传递参数时 遇到了这个问题 仔细对照了代码

package com.at.servlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

public class AddServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) {

        String fname= request.getParameter("fname");
        String fheightStr=request.getParameter("fheight");
        int fheight=Integer.parseInt(fheightStr);
        String fweightStr=request.getParameter("fweight");
        int fweight=Integer.parseInt(fweightStr);
        String yanzhistr=request.getParameter("handsome");
        int yanzhi=Integer.parseInt(yanzhistr);

        System.out.println("fname=" + fname);
        System.out.println("fheight="+fheight);
        System.out.println("fweight="+fweight);
        System.out.println("yanzhi="+yanzhi);


        }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }
}

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>输入你的信息</title>
</head>
<body>
      <form action="add" method="post">
          名字:<input type="text" name="fname"/><br/>
          身高:<input type="text" name="fheight"/><br/>
          体重:<input type="text" name="fweight"/><br/>
          颜值:<input type="text" name="handsome"/><br/>
          <input type="submit" value="提交你的信息"/>
      </form>
</body>
</html>

nteger 那里转换也没啥问题啊  在我百思不得其解时  我注意到了我下面那个html文件的命名是add.html 而我之前在网页上的url都是add 所以我后面改为add.html就可以了....

所以说这个文件的命名还是非常重要的 要注意细节啊!!!!!!!!!

最后

以上就是清新小伙最近收集整理的关于类型 异常报告 消息 null 描述 服务器遇到一个意外的情况,阻止它完成请求。 例外情况 java.lang.NumberFormatException: null java.base/的全部内容,更多相关类型内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(123)

评论列表共有 0 条评论

立即
投稿
返回
顶部