【已解决】The server cannot or will not process the request due to something that is perceived to be ...

错误描述如下:
400-Bad Request 错误描述错误描述:
The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).

意思是服务器不处理来自客户端的错误请求,一般是请求语法,无效的请求信息等错误原因。

在学习Spring MVC框架 用表单的请求参数绑定实体类时遇到,参考论坛中的帖子发现提交的表单数据类型与实体类数据类不一致导致

jsp页面 form 表单代码:


    <%-- 请求参数绑定实体类 --%>
    <form action="params/saveAccount" method="post">
        <label>姓名</label><input type="text" name="username"><br>
        <label>密码</label><input type="text" name="password"><br>
        <label>金额</label><input type="text" name="money"><br>
        <label>用户姓名</label><input type="text" name="user.uName"><br>
        <label>用户年龄</label><input type="text" name="user.age"><br>
        <input type="submit" value="提交">
    </form>

Account 实体类 成员变量 数据类型 代码:

    private String username;
    private int password;
    private double money;

    private User user;

导致错误的表单提交:
错误的表单passwordAccount 实体类中 数据类型是 int
提交的密码数据是字符串导致错误

解决:
将表单的提交数据改为与实体类中对应的数据类型

参考贴原文链接:https://blog.csdn.net/fallwind_of_july/article/details/90451135

发布了17 篇原创文章 · 获赞 0 · 访问量 140

猜你喜欢

转载自blog.csdn.net/weixin_46539792/article/details/105389551