I am a beginner in Spring. I am trying to build login page for an application. The problem is I am not able to load the login page from the controller. Below is the code for controller.
@RestController
public class RootViewController {
@RequestMapping(value = "/", method = RequestMethod.GET)
public ModelAndView login() {
Map map = Collections.singletonMap("title", "Welcome! Login the website");
return new ModelAndView("sites/test", map);
}
}
The method returns status 404 error. The test page is in jade. The configuration file code is given below.
@Configuration
class JadeConfig {
@Bean
public SpringTemplateLoader templateLoader() {
SpringTemplateLoader templateLoader = new SpringTemplateLoader();
templateLoader.setBasePath("classpath:template/");
templateLoader.setEncoding("UTF-8");
templateLoader.setSuffix(".jade");
return templateLoader;
}
@Bean
public JadeConfiguration jadeConfiguration() {
JadeConfiguration configuration
= new JadeConfiguration();
configuration.setCaching(false);
configuration.setTemplateLoader(templateLoader());
return configuration;
}
}
The test file exists in resources/template/sites
below is the gradle dependencies
//Spring
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web'
compile group: 'de.neuland-bfi', name: 'spring-jade4j', version: '1.2.5'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa'
The client page test should run on port 8081 set through configuration file.
server:
port: 8081