How to return a hyperlink from spring boot controller?

k.prerna :

I want to return a hyperlink in the response body for a get request using Spring Boot, but i am getting string as a response and not link

@GetMapping("/getLinkToFile/{id}")
public URL getLinkToFile(@PathVariable int id) throws Exception {
    URL base = new URL("https://file-examples.com/wp-content/uploads/2017/02/file_example_CSV_5000.csv");
    return base;
}
Dulaj Kulathunga :

Can you try this one please , then you will get idea to do archive your problem

@GetMapping(value = "/test")  // just for samples 
  public String getLinkToFile() throws Exception {
    String body =
        "<HTML><body> <a href=\"https://file-examples.com/wp-content/uploads/2017/02/file_example_CSV_5000.csv\">Link clik to go</a></body></HTML>";
    return (body);

  }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=322775&siteId=1