Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →To receive an array in Java, first check how jQuery sends it. For a JSON request body, bind it with Spring MVC’s @RequestBody; for URL-encoded form parameters, bind repeated values with @RequestParam or read them with Servlet getParameterValues(). The parameter name must match exactly: items[] and items are different names.
Choose JSON or form parameters
Use JSON for nested or structured data, or when the request may grow to include more fields. Use URL-encoded form parameters for a simple list of scalar values when that matches the endpoint’s contract. The choice determines both the request format and how Java reads it.
| Request format | Typical use | jQuery request | Spring MVC binding |
|---|---|---|---|
| JSON body | Structured data, arrays of objects, or an extensible request | JSON.stringify(...) with JSON contentType |
@RequestBody |
| URL-encoded form parameters | A simple list of scalar values | Repeated keys, bracketed by default or unbracketed with traditional: true |
@RequestParam |
Send JSON and bind it with Spring MVC
For an object containing an array, serialize the payload as JSON, set the request contentType, and disable jQuery’s automatic parameter processing because data is already a JSON string. In this example, dataType indicates that the client expects a JSON response; it does not set the request format. See the jQuery.ajax() documentation and Spring’s @RequestBody reference.
const values = ["red", "green", "blue"];
$.ajax({
url: "/api/colors",
method: "POST",
data: JSON.stringify({ items: values }),
contentType: "application/json; charset=UTF-8",
dataType: "json",
processData: false
});
Define a request type whose property matches the JSON field, then accept it with @RequestBody:
public record ColorRequest(List<String> items) {}
@PostMapping("/api/colors")
public ResponseEntity<?> colors(@RequestBody ColorRequest request) {
List<String> items = request.items();
return ResponseEntity.ok(Map.of("count", items.size()));
}
If the JSON document is the array itself rather than an object, send JSON.stringify(values) and bind the body as @RequestBody List<String> items. An object such as {"items":[...]} is usually easier to extend later with additional request fields.
Send form parameters and bind repeated values
Form encoding is not JSON. jQuery’s default deep serialization turns an array under items into bracketed repeated keys, such as items[]=red&items[]=green. Request that exact name in Spring:
Rank #2
$.ajax({
url: "/api/colors",
method: "POST",
data: { "items[]": ["red", "green", "blue"] },
traditional: false
});
@PostMapping("/api/colors")
public ResponseEntity<?> colors(@RequestParam("items[]") List<String> items) {
return ResponseEntity.ok(Map.of("count", items.size()));
}
If the server contract expects the unbracketed parameter name, set traditional: true. jQuery then sends repeated keys such as items=red&items=green, which Spring can bind from @RequestParam("items"). The jQuery API documents that array serialization depends on the traditional setting; its jQuery.param() documentation describes JSON as an alternative for complex data.
$.ajax({
url: "/api/colors",
method: "POST",
data: { items: ["red", "green", "blue"] },
traditional: true
});
@PostMapping("/api/colors")
public ResponseEntity<?> colors(@RequestParam("items") List<String> items) {
return ResponseEntity.ok(Map.of("count", items.size()));
}
Use a collection such as List<String> or an array in Java when the request contains repeated values. A scalar parameter is not the right target for a list.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallRead form arrays in a plain Servlet
Without Spring MVC binding, call getParameterValues() with the exact form parameter name. If an endpoint intentionally accepts either convention, check both:
String[] items = request.getParameterValues("items[]");
if (items == null) {
items = request.getParameterValues("items");
}
For a JSON request body, read from request.getInputStream() or a Reader and deserialize it with the JSON library already used by the application. JSON text is in the body; it is not a query parameter and cannot be retrieved with getParameterValues().
Rank #4
Diagnose a null or missing array
Check the request as sent, then make the Java binding agree with it:
Quick Recap
Best Value
- Open the browser’s Network panel and inspect the request’s
Content-Typeand payload. - If the payload is form-encoded, compare its parameter name exactly with the Java binding.
items[]anditemsare distinct keys. - If values appear as repeated form keys, bind a collection or array and use
@RequestParamin Spring, orgetParameterValues()in a Servlet. - If the payload is JSON, set
contentType: "application/json; charset=UTF-8", pass a serialized JSON string, and setprocessData: false. Bind with@RequestBodyin Spring. - Do not confuse
contentTypewithdataType: the former describes the request body; the latter describes the response jQuery should expect. - Validate that the value is present, non-empty if required, of the expected element type, within the endpoint’s size limits, and authorized for the caller.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Free tools Windows power users keep installed
One-click scans. No signup required.

