When the basic data and file data in the form are submitted in the post method at the same time, the basic data cannot be received.

Scenario, use postman to simulate form submission, pass the following data to the server side, the server side receives the basic data and saves the file to the local and then returns the postman data The
write picture description here
server side does not get the basic data (userNo and requestNo), the server side uses

String userNo=request.getParameter("userNo");
String requestNo=request.getParameter("requestNo");

This return is null; the
solution :
1. Use the jar package to parse the data

2. Use ajax to asynchronously transfer basic data or asynchronously transfer files
(async is equivalent to ajax opening a sub-thread by itself)

PS Asynchronous Notes:
Original text: Personal understanding of synchronous and asynchronous in js
write picture description here
Event delegation : the capture of events in outer elements is
"synchronous" - it reminds people of the word "together"; "asynchronous", literally, it seems It is to do something on different (different) ways, the first word that comes to mind may be "one side...side...", such as 'Xiao Ming eats ice cream while doing homework', this is totally fine, after the ice cream is finished, the homework is also written Finished, this is asynchronous? That would be a big mistake!
write picture description here

ps:

问:
ajax异步时,触发ajax去修改数据库,如果频率过高修改数据时,会出现有些没有修改,但是同步以后就不会出现这种问题?
答:
因为第一笔数据还没ok,第二笔数据就来了
问:
tomcat不是多线程吗?一次请求创建一个线程
答:
在异步下,请求还没ok,就给返回结果了,是多线程,第一次把1修改成2,还没修改成功,第二次请求就来了,读到的还是1(脏读)
问:
数据库开着的,但是没有修改到,不是脏读
ps:脏读是修改成功了,但是读到的还是以前的数据
解决:
改为ajax同步
一般写数据用异步

The number of parameters submitted by ps:post exceeds 10,000, resulting in failure to obtain subsequent data. The
number of parameters exceeds the upper limit of tomcat, resulting in failure to obtain the problem. Solve the problem:
write picture description here

ps: A situation similar to the above but different : the
form data is submitted using the get method, the key-value added after the url is lost
, the data behind the url is lost, and how the form sends put and delete requests
write picture description here
write picture description here

PS: get and post method notes

  1. get method:
    when the get method is submitted, the key-value value of the form is directly appended to the url, but there is a disadvantage: most browsers limit the number of parameters that can be included in the get request
  2. Post method:
    When using post naming, you do not need to add any parameters to the url, but get the output stream from URLConnection, and write the key-value pair into the stream.
    write picture description here
    Attach original link java to post data code
    write picture description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325535465&siteId=291194637