Uploaded image for project: 'Spring Data REST'
  1. Spring Data REST
  2. DATAREST-1323

Cannot return plain string from @BasePathAwareController method

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Repositories
    • Labels:
      None

      Description

      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?

       

       

        Attachments

          Activity

            People

            Assignee:
            olivergierke Oliver Drotbohm
            Reporter:
            doogiemuc Doogiemuc
            Last updater:
            Spring Issues Spring Issues
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: