How to use getRequestUri().getRawQuery() in the url on Java escape -


as know url not allow special character there, need encode that: : metadata=[{name: serialnumber, value: aaaaaaaaa},{name: register, value: abcde}] in url

i tried encode work

string abc= java.net.urlencoder.encode("http://localhost:9080/myapp/myapp/search?metadata=[{name: serialnumber, value: aaaaaaaaa},{name: register, value: abcde}]", "utf-8"); 

but why fail following if use info.getrequesturi().getrawquery() instead?

public response search(@context final uriinfo info, @context final httpheaders httpheaders) throws exception {         string requesturi = java.net.urlencoder.encode(info.getrequesturi().getrawquery(), "utf-8"); 

error:

caused by: java.net.urisyntaxexception: illegal character in query 

how can encode if use info.getrequesturi().getrawquery()

this might due white space in metadata. may either -

  1. remove white spaces (metadata=[{name:serialnumber,value:aaaaaaaaa},{name:register,value:abcde}]
  2. replace white spaces + mentioned in question

hope work!


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -