API Documentation Section
@Target ({elementtype.parameter, Elementtype.method, Elementtype.field}) @Retention (retentionpolicy.runtime) public @interface Formparam { /** * Defines the name of the form parameter whose value would be used * to initialize T He value of the annotated method argument. the name is * specified-decoded form, any percent encoded literals within the value * would not be decoded and W Ill instead be treated as literal text. e.g. if * The parameter name is "a B" then the value of the annotation is "a B", * <i>not</i> "a+b" or "a%20b". * /String value ();}
By default, it is not encoded.
The following is an introduction:
Https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Web_Platform/5/html/RESTEasy_Reference_Guide/_ Encoded_and_encoding.html
Jax-rs allows you to get encoded or decoded
@*
Param
s and specify path definitions and parameter names using encoded or decoded strings. The
@javax.ws.rs.Encoded
Annotation can used on a class, method, or parameter. By default, injected
@PathParam
and
@QueryParam
Is decoded. Adding the
@Encoded
Annotation means that the value of these parameters would be is provided in encoded form.
@Path ("/") public class MyResource { @Path ("/{param}") @GET the public String GET (@PathParam ("param") @ Encoded String param) {...}
In the previous example, the value of the
@PathParam
Injected into the
param
of the
get()
Method would be URL encoded. Adding the
@Encoded
annotation as a parameter annotation triggers this effect. can also use the
@Encoded
annotation on the entire method and any combination of
@QueryParam
Or
@PathParam
' s values would be encoded.
@Path ("/") public class MyResource { @Path ('/{param} ') @GET @Encoded public String GET (@QueryParam ( "foo") string foo, @PathParam ("param") string param) {}}
In this example, the values of the
foo
Query parameter and the
param
Path parameter would be injected as encoded values. You can also set the default to being encoded for the entire class.
@Path ("/") @Encodedpublic class Classencoded { @GET public string GET (@QueryParam ("foo") string foo) {}}
The
@Path
annotation have an attribute called
encode. This controls whether the literal part of the "value supplied" (that's, the characters that's not part of a template vari Able) is url-encoded. If
true
, any characters in the URI template that is not valid would be automatically encoded. If
false
, then all characters must is valid URI characters. By default, the
encode
attribute are set to
true
. (You can also encode the characters by hand.)
@Path (value= "Hello%20world", Encode=false)
As with
@Path.encode()
, this controls whether the specified query parameter name should is encoded by the container before it tries to find the Query parameter in the request.
@QueryParam (value= "Hello%20world", Encode=false)
Jax-rs Receive parameter Note default is non-encoded