3

Before you minus this question, you should know I searched for solution and didn't find it.

I want to return String by rest endpoint:

    @GET
    @Path("/getMyString")
    @Produces({ MediaType.APPLICATION_JSON })
    public Response getId() {
    String s = "this is my string";
    (...)
    return Response.ok(s).build();
    }

But in view I receive char array (result in firebug):

Resource { 0="t", 1="h", 2="i", more...}

In front I use angular resource like:

blablaResources.factory('AngularApp', [ '$resource', function($resource) {
    return $resource(contextPath + '/.rest/v1/someService', {}, {
        (... other methods ...)
        getString : {
            method : 'GET',
            url : contextPath + '/.rest/v1/someService/getMyString'
        }
    });
} ]);

Is there any wrapper class for String or annotation to send it like:

Resource { value = "this is my string" }

or just normal

"this is my string"

Thanks for any constructive response :)

3
  • How does the response JSON look like on the wire (check with developer console or curl)? Just a string or something weird? Commented Jun 26, 2014 at 7:04
  • Did u try to create the result string as a JSON string directly? I mean...did u try to build String s="{this is my string}"? Commented Jun 26, 2014 at 7:05
  • What JAX-RS implementation do you use ? Commented Jun 26, 2014 at 7:14

1 Answer 1

5

Try to use

@Produces({ MediaType.TEXT_PLAIN })
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.