2

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;
}
Sudhir Ojha
  • 3,247
  • 3
  • 14
  • 24
k.prerna
  • 31
  • 1
  • 6

1 Answers1

3

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);

  }
Dulaj Kulathunga
  • 1,248
  • 2
  • 9
  • 19