Monday 15 February 2010

spring-boot application displaying html code for view when executed in the browser -



spring-boot application displaying html code for view when executed in the browser -

i start work spring-boot in spring projects, , right facing problem:

i have 1 spring-boot application main class:

@configuration @enableautoconfiguration @componentscan public class application { public static void main(string[] args) { springapplication.run(application.class, args); } }

and controller:

@controller public class acessocontroller { @requestmapping(value = "/signin") public string signin(model model) { homecoming "acesso/signin"; } @requestmapping(value = "/admin") public string admin(model model) { homecoming "private/admin"; } @requestmapping(value = "/index") public string index(model model) { homecoming "public/index"; } }

when run application , seek access url mapping /signin, example, browser display html code view, instead of actual content.

what doing wrong here?

are trying render view using template engine, or homecoming static html file?

if trying render template, not have right dependency in place pull in template engine. (per code, believe trying do.) if don't intend utilize template engine templates, want 1 render html you. depending on spring-boot setup, seek starting spring-boot-starter-web, or pull in thymeleaf (spring-boot-starter-thymeleaf) or freemarker (spring-boot-starter-freemarker) specifically.

if want homecoming static content , not want custom configuration, you'll need place files in location , not need specific controller request mappings.

http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-spring-mvc-static-content

spring spring-mvc spring-boot

No comments:

Post a Comment