The issue with this URI is that there is a space character in the query parameter value, which is not allowed. To fix this, you need to encode the query parameter value using URL encoding.

Here's the corrected code:

String queryParamValue = "12x24 frame";
String encodedQueryParamValue = URLEncoder.encode(queryParamValue, StandardCharsets.UTF_8.toString());
URI uri = URI.create("/shop-categories/categories?q=" + encodedQueryParamValue);

This will encode the query parameter value as 12x24+frame, which is a valid URL-encoded value

fix code in java URIcreateshop-categoriescategoriesq=12x24 frameIllegal character in query at index 35 shop-categoriescategoriesq=12x24 frame

原文地址: https://www.cveoy.top/t/topic/d89b 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录