客户端错误,我猜与 utf-8 或与表单标签相关的东西有关但是解决不了

问题描述

我正在尝试使用 Spring MVC 表单提交表单请求,并使用 Hibernate 将数据添加到 db。但它显示了这样的错误“由于某些被认为是客户端错误(例如,格式错误的请求语法、无效的请求消息帧或欺骗性的请求路由),服务器无法或不会处理请求。 “ 我研究了这个问题并在这里查看了几乎所有相关问题,但找不到适合我的解决方案。

我的jsp文件

from functools import reduce
from operator import or_

words = ['software','engineer']
or_filter = reduce(or_,(Q(job_title__icontains=word) for word in words))


Vacancy.objects.filter(or_filter)

我的 UserController 类中该表单操作的请求处理程序方法


<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<html>

<head>
    <title>New Plan Form</title>

<Meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<link rel="stylesheet" type="text/css"
    href="${pageContext.request.contextpath}/resources/css/new-plan-form.css">
    
<link rel="stylesheet" type="text/css"
    href="${pageContext.request.contextpath}/resources/js/jquery.datetimepicker.min.css">
    
<script type="text/javascript" src="${pageContext.request.contextpath}/resources/js/jquery.js"></script>
<script type="text/javascript" src="${pageContext.request.contextpath}/resources/js/jquery.datetimepicker.full.js"></script>
    
</head>


<body>

    <h2>New Plan Form</h2>

    <div class="container">
        <form:form action="saveNewPlan" modelattribute="newPlan" method="POST" acceptCharset="utf-8">
    
        <div class="row">
                <div class="col-25">
                    <label for="fname">Title</label>
                </div>
                <div class="col-75">
                    <form:input path="title" id="title" name="title"
                        placeholder="Title" />
                </div>
            </div>
            

            <div class="row">
                <div class="col-25">
                    <label for="subject">Description</label>
                </div>
                <div class="col-75">
                    <form:textarea path="description" id="description"
                        name="description" placeholder="Write about plan in detail"
                        style="height:200px" />

                </div>
            </div>
            
            <div class="row">
                <div class="col-25">
                    <label for="lname">Begin Date</label>
                </div>
                <div class="col-75">
                    <form:input path="beginDate" id="beginDate" name="beginDate"
                        placeholder="When you will begin to realize this plan" />
                        <script type="text/javascript">
                          $("#beginDate").datetimepicker();
                        </script>
                </div>
            </div>
            
            <div class="row">
                <div class="col-25">
                    <label for="lname">End Date</label>
                </div>
                <div class="col-75">
                    <form:input path="endDate" id="endDate" name="endDate"
                        placeholder="Until when you should finish this plan" />
                        <script type="text/javascript">
                          $("#endDate").datetimepicker();
                        </script>
                </div>
            </div>
            
            <div class="row">
                <input type="submit" value="Submit">
            </div>

        </form:form>

     </div>

</body>

</html>

以及我的配置文件的 ViewResolver 部分

@Controller
@RequestMapping("/user")
public class UserController {

    @PostMapping("/saveNewPlan")
    public String savePlan(@modelattribute("newPlan") Plan thePlan) {
        
        planService.savePlan(thePlan);
        
        
        return "home-page";
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)