简体   繁体   English

在 Spring mvc 控制器中访问 Javascript 数组

[英]Access Javascript array in Spring mvc controller

Right now I am sending some parameters through URL to the controller in spring mvc project.现在我正在通过 URL 向 spring mvc 项目中的控制器发送一些参数。 If the parameters are too long the url is more than 2083 characters which IE do not accept more than 2083 characters in a url.So I am thinking to access the front end JavaScript array in the backend controller.如果参数太长,则 url 超过 2083 个字符,IE 不接受 url 中超过 2083 个字符。所以我想访问后端控制器中的前端 JavaScript 数组。 How is it possible or any other better alternative suggestion please?怎么可能或任何其他更好的替代建议?

It is not possible "to access the front end JavaScript array in the backend controller".不可能“访问后端控制器中的前端 JavaScript 数组”。 The JavaScript array (and the logic around it) is in the browser, and your Java backend is on your server. JavaScript 数组(及其周围的逻辑)在浏览器中,而您的 Java 后端在您的服务器上。 The communication path are the URLs.通信路径是 URL。

You're probably currently sending your parameters with GET requests.您当前可能正在使用 GET 请求发送参数。 You have to switch to POST requests, then you'll be able to send much much more than 2000 characters.您必须切换到 POST 请求,然后才能发送 2000 多个字符。

See Spring docs section " Mapping Requests With @RequestMapping ", depending on the Spring version you use, eg:请参阅 Spring 文档部分“ Mapping Requests With @RequestMapping ”,具体取决于您使用的 Spring 版本,例如:

Use POST instead of GET while making the call to the server side.在调用服务器端时使用POST而不是GET And have your data in the payload of the request.并将您的数据放在请求的有效负载中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM