BAEL-3822 Spring Boot MVC controller return HTML (#8988)
Co-authored-by: Oskar <>
This commit is contained in:
@@ -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>";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user