Код: Выделить всё
@Controller
//@RequestMapping("/")
//@ComponentScan("com.spring")
//@EnableAutoConfiguration
public class HomeController {
@Value("${framework.welcomeMessage}")
private String message;
@RequestMapping("/hello")
String home(ModelMap model) {
System.out.println("hittin the controller...");
model.addAttribute("welcomeMessage", "vsdfgfgd");
return "Hello World!";
}
@RequestMapping(value = "/indexPage", method = RequestMethod.GET)
String index(ModelMap model) {
System.out.println("hittin the index controller...");
model.addAttribute("welcomeMessage", message);
return "welcome";
}
@RequestMapping(value = "/indexPageWithModel", method = RequestMethod.GET)
ModelAndView indexModel(ModelMap model) {
System.out.println("hittin the indexPageWithModel controller...");
model.addAttribute("welcomeMessage", message);
return new ModelAndView("welcome", model);
}
}
Код: Выделить всё
Welcome to Spring Boot
Message: ${message}
Код: Выделить всё
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
SpringBootPlay
SpringBootPlay
0.0.1-SNAPSHOT
org.springframework.boot
spring-boot-starter-parent
1.4.0.RELEASE
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-test
test
org.springframework.boot
spring-boot-starter-tomcat
javax.servlet
jstl
org.apache.tomcat.embed
tomcat-embed-jasper
provided
org.springframework.boot
spring-boot-starter-actuator
commons-logging
commons-logging
1.1.3
org.apache.commons
commons-io
1.3.2
log4j
log4j
1.2.17
com.jcabi
jcabi-log
0.17
1.8
com.spring.play.BootLoader
${basedir}/../..
/
org.springframework.boot
spring-boot-maven-plugin
org.apache.maven.plugins
maven-surefire-plugin
false
Код: Выделить всё
@EnableAutoConfiguration
@SpringBootApplication
@ComponentScan({ "com.spring.controller" })
@PropertySources(value = { @PropertySource("classpath:/application.properties") })
public class BootLoader extends SpringBootServletInitializer {
final static Logger logger = Logger.getLogger(BootLoader.class);
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(BootLoader.class);
}
public static void main(String[] args) {
SpringApplication.run(BootLoader.class, args);
}
}
Страница ошибки Whitelabel
Это приложение не имеет явного сопоставления для /error, поэтому вы рассматриваете это как запасной вариант.
Среда, 21 сентября, 21:34:18 по восточному времени 2016 г. Произошла непредвиденная ошибка (тип=Не найден, статус=404).
]/WEB-INF/jsp/welcome.jsp
< strong>Мое приложение.свойства
Код: Выделить всё
spring.mvc.view.prefix: /WEB-INF/jsp/
spring.mvc.view.suffix: .jsp
framework.welcomeMessage=Welcome to Dashboard
Подробнее здесь: https://stackoverflow.com/questions/396 ... ing-a-simp