$.ajax({url:"http://localhost:8080/TestApp/resources/Test",
type:"GET",
data:userName :"userName",
cache: false,
success:function(result){
alert(result);
},
});
Above is the JQuery code I'm using to call the service. How can I get the userName
parameter to the
@GET
@Produces("text/html")
public String getHtml() {
return "Hello ";
}
Similar to a request.getParameter("")
in servlet. In my understating @QueryParam
, @PathParam
, @FormParam
are used for different purposes or can they be used to to get the parameter. (I have tried all three and failed). Kindly correct me if I'm doing anything wrong.
The RuntimeException could not be mapped to a response, re-throwing to the HTTP container com.sun.jersey.api.container.ContainerException: Exception obtaining parameters at com.sun.jersey.server.impl.inject.InjectableValuesProvider.getInjectableValues(InjectableValuesProvider.java:54) at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$EntityParamInInvoker.getParams(AbstractResourceMethodDispatchProvider.java:137) at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:165) at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:70) at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:279) at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:86) at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:136)
Did the changes and getting an exception as above.
The data attribute has to be a plain js object, String or an array (See http://api.jquery.com/jquery.ajax/)
So, in your code, the data element ought to be