`

错误400报The request sent by the client was syntactically incorrect ()

 
阅读更多

框架:为springmvc+spring+mongodb

目的:想做一个时间相关的查询(需要比较大小),后端是用Date来接收的,前端是用input的date标签传送值

    前端jsp页面:

    后端查询模型

 

说明:在我前端填写了时间之后,点击查询提交表单,结果就出现:错误400报The request sent by the client was syntactically incorrect ()然后各种不知道怎么回事,以前从来没出现这种情况;因为我默认springmvc在controller里面会根据数据模型里面的字段类型把前端传来的值自动转型,结果经过查询才知道,尼玛springmvc接收来的都是String类型的,所以必须要用string类型的来接收:如下

 好了现在传值,后台不会报错了;但是之后出现了一个问题:不能查询,因此必须又要把string类型的用DateUtil.formatDate(startDate,"yyyy-dd-mm")转了,再来比较!

 特别说明:刚刚试了一下上面的格式转换,结果查出来的不准确;然后看了下源码,发现dd必须要大写才能查出准确的结果:因此这些细小的地方真的不得不注意如下:

 

总结:1.对于springmvc来说:前端传值的名字和后端的名字一定要对应(免得后端处理);

        2.springmvc的controller里面接收到的前端数据(都是string类型的)这里更正一下,因为在使用中后台有些类型controller貌似可以自动转换,因此要注意调整!一定要注意用string类型的字段接收

 

 

  • 大小: 16.2 KB
  • 大小: 11.4 KB
  • 大小: 11 KB
  • 大小: 5.8 KB
0
0
分享到:
评论

相关推荐

    servlet2.4doc

    The doFilter method of the Filter is called by the container each time a request/response pair is passed through the chain due to a client request for a resource at the end of the chain. doGet...

    SSD7 选择题。Multiple-Choice

    (b) the name of the table, the names of the table's attributes, the data types of the table's attributes, the formats of the table's attributes, and the maximum number of rows that the table can have...

    Hardware Design Based on Verilog HDL

    satisfy are also given, and can be used for the comparison of syntactically different programs. The thesis also presents a number of other results. The use of a temporal logic to specify the semantics...

    MIBBrowser8.rar

    the SNMP Trap and SNMP Inform packets that were sent from arbitrary SNMP devices or applications on the network. MIB Browser can monitor several SNMP devices simultaneously and contains features like...

    Design Concepts in Programming Languages

    The book's unique approach is based on a family of syntactically simple pedagogical languages that allow students to explore programming language concepts systematically. It takes as premise and ...

    Java 英文习题及答案

    Which of the following Java statements is syntactically correct and semantically identical to the program segment? (a) int[] arr= {15, 17, 19}; (b) int[3] arr = {15, 17, 19}; (c) int arr = {15, 17, ...

    UML(统一建模语言)---介绍

    Meta-model – model that describes another model, are the concepts that define a syntactically correct model. UML metamodel is defined using Meta Object Facility (MOF), a meta-metamodel that is ...

    Beginning CSS Preprocessors(Apress,2015)

    Learn how preprocessors can make CSS scalable and easy to maintain....What are the features of Sass (Syntactically Awesome Stylesheets) What is Compass (COMPrehensive ASSembler) What is Less (Leaner SS)

    Java.EE.and.HTML5.Enterprise.Application.Development

    Employ Syntactically Awesome Stylesheets, CSS3, and Sassy CSS Table of Contents Chapter 1 Introduction to Java EE and HTML5 Enterprise Development Chapter 2 Persistence Chapter 3 RESTful Resources ...

    Android代码-AQuery

    AQuery is a lightweight library that allows UI manipulation in a syntactically similar way to the Javascript library JQuery. AQuery aims to remove the boilerplate code that comes with UI manipulation ...

    快速JSON序列化Easyjson.zip

    such cases, so that they may be fixed sooner.Unsafe package is used by the code. While a non-unsafe version of easyjson can be made in the future, using unsafe package simplifies a lot of code by...

    《Oracle数据库编程指南》之11:运算符(Operators)

    Syntactically, an operator appears before or after an operand or between two operands. Operators manipulate individual data items called operands or arguments. Operators are represented by special ...

    在vue项目中使用sass语法问题

    Sass(英文全称:Syntactically Awesome Stylesheets)是一个最初由Hampton Catlin设计并由Natalie Weizenbaum开发的层叠样式表语言。在开发最初版本之后,Weizenbaum和Chris Eppstein继续通过SassScript来继续扩充...

    初入Sass

    **Sass** (Syntactically Awesome StyleSheets),是由buby语言编写的一款css预处理语言,和html一样有严格的缩进风格,和css编写规范有着很大的出入,是不使用花括号和分号的,所以不被广为接受。 Sass 是一款强化 ...

    sass简介_动力节点Java学院整理

    Sass 是Syntactically Awesome Stylesheete Sass的缩写,是由Hampton Catlin开发的。 Sass可以简化你的Css工作流,并可以使你的Css的扩展和维护工作变的更加容易! 例如,曾几时何,因为客户的需求的变更,你必须...

    在create-react-app中使用sass的方法示例

    Sass(英文全称:Syntactically Awesome Stylesheets)是一个最初由Hampton Catlin设计并由Natalie Weizenbaum开发的层叠样式表语言。Sass是一个将脚本解析成CSS的脚本语言,即SassScript。Sass包括两套语法。最开始...

    Django中如何使用sass的方法步骤

    作为一个运维开发,不像业务开发只专注后端业务开发即可,常常需要自己来构建前端的东西,当然系统交互体验说的过去就行,要求也没有业务系统...Sass or (Syntactically awesome style sheets) is a preprocessor scri

Global site tag (gtag.js) - Google Analytics