Home > Back-end >  Spring gives the URL parameter encoding do not agree with the query
Spring gives the URL parameter encoding do not agree with the query

Time:10-04

Type in Chinese query keywords, such as "farming", point queries, URL the URL in the address bar is as follows:
http://localhost:8080/crm/customer/list.action? CustType=& amp; CustFileYear=& amp; E5 custAddress=% % 86% 9 c & amp; CustSource=
Visible custAddress is utf-8
Check out of the results is correct,

But, at that time some paging button "next page" again, the URL the URL in the address bar is as follows:
http://localhost:8080/crm/customer/list.action? CustType=& amp; CustFileYear=& amp; CustAddress=agriculture & amp; CustSource=& amp; Page=2 & amp; Rows=10
CustAddress into Chinese, go wrong,

Java. Lang. IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

Don't advised me to reduce the TOMCAT version, because the JAVA version drop TOMCAT and reduced, involves the code change is too big,
Consult! Thank you,

CodePudding user response:

Code can be added to the url after the back

CodePudding user response:

There is a better way? Please help

CodePudding user response:

When you click the next page, your program for what?

CodePudding user response:

//display the "next page" button
If (page. Getpages () & lt; PageCount) {
String nextUrl=append (url, "page", page. Getpages () + 1);
NextUrl=append (nextUrl, "rows", page, getSize ());
Writer. Print (" & lt; Li> " );
Writer. Print (" & lt; Li>
" );
} else {
Writer. Print (" & lt; Li class=\ "disabled " & gt;
" );
Writer. Print (" & lt; Li class=\ "disabled " & gt;
" );
}
The URL is assembled

CodePudding user response:

In the background when receiving parameters and transcoding, into utf-8 format, directly in the database can query, remember Settings at the front end ajax contentType as utf8 format, consistent so there would be no problem
  • Related