Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot return plain string from @BasePathAwareController method [DATAREST-1323] #1682

Open
spring-projects-issues opened this issue Dec 19, 2018 · 0 comments
Assignees
Labels

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Dec 19, 2018

Doogiemuc opened DATAREST-1323 and commented

It is not possible to return a plain String from a rest controller when it is annotated with @BasePathAwareController.   

This normal controller works (but in this controller I for example couldn't inject PersistentEntityResourceAssembler)

@RestController
@RequestMapping("${spring.data.rest.base-path}")   // to expose under correct basepath
public class UserRestController {
  @RequestMapping("/getStringExample")   
  public @ResponseBody String getStringExample() {
    return "Some dummy String"
  }
}

 

But this does not work:

@BasePathAwareController
public class UserRestController {
  @RequestMapping("/getStringExample")   
  public @ResponseBody String getStringExample() {
    return "Some dummy String"
  }
}

This returns a quoted string.   Adding produces = "text/plain" also doesn't help. It doesn't work no matter if you use @ResponseBody or not.

Even when you return a ResponseEntity.ok("Some dummy String");   the result will still be quoted in the final response.

 

How can I return a plain String (e.g. a token) from a @BasePathAwareController?

 

 


Reference URL: https://stackoverflow.com/questions/33687722/spring-data-rest-custom-method-return-string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants