2020/9/21 daily report controller layer accepts ajax data as null

Project scene:

The serialize() method is used to pass parameters in ajax, and the value received by the controller layer is inserted into the database.

Problem Description:

1. The parameter received by the controller layer is null
2. Cause: java.sql.SQLException: Data truncated for column'year' at row 1

Cause Analysis:

1. The name in the input tag does not correspond to the field in the Thesis class. (The commented out is wrong, the uncommented is correct)

Insert picture description here
Insert picture description here

2. The data accepted by the year field is too long and exceeds the byte range.

solution:

1. Modify the name attribute in the label in the input to be the same as the field in the Thesis class.
2. Expand the byte length that the year can hold

Regular expression

Insert picture description here

Guess you like

Origin blog.csdn.net/qq1350975694/article/details/108713304