BAEL-3822 Spring Boot MVC controller return HTML (#8988)

Co-authored-by: Oskar <>
This commit is contained in:
Roman
2020-03-30 22:25:55 +02:00
committed by GitHub
parent 1734250d97
commit 8bfb7df3b2
3 changed files with 59 additions and 0 deletions
@@ -0,0 +1,12 @@
package com.baeldung.html;
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
@SpringBootApplication
public class HtmlApplication
{
public static void main(String[] args) {
SpringApplication.run(HtmlApplication.class, args);
}
}
@@ -0,0 +1,17 @@
package com.baeldung.html;
import org.springframework.http.*;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;
@Controller
public class HtmlController
{
@GetMapping(value = "/welcome", produces = MediaType.TEXT_HTML_VALUE)
@ResponseBody
public String welcomeAsHTML()
{
return "<html>\n" + "<header><title>Welcome</title></header>\n" +
"<body>\n" + "Hello world\n" + "</body>\n" + "</html>";
}
}