简体   繁体   中英

JAX-RS PathParam not working

Trying to allow forward slashes using JAX-RS @PathParam . What happens is that it takes the backend of the value and not the whole value. Example below

METHOD CODE

@PUT
@POST
@Path("/temp/{keyValue:.+}")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public void setValues(@PathParam("keyValue") PathSegment myvalue) {
  for (String key : myvalue.getMatrixParameters().keySet()) {
    System.out.println(batch)
  }

TEST URL

https://localhost:8443/*path*/temp/keyValue;key1=THIS/SUCKS

RESULT

batch = SUCKS

DESIRED RESULT

batch = key1=THIS/SUCKS

I have tried changing the regex in the method signature and I can not make this work. If things are url encoded, I am able to get it pass through with the %2F . However, if I change my Apache httpd to AllowEncodedSlashes On , it would break the rest of my site. Any ideas on what it could be?

I am running httpd -> tomcat -> restService (JAX-RS)

I couldn't get this to work correctly, so I rewrote it so that it accepts a string that is converted to a JSON object. Sending parameters in a URL string is a bad idea because URLs have a character limit. I am now sending it as data in an AJAX call.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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