I'm trying to get Spring project to work with jsf views, I followed http://www.beyondjava.net/blog/jsf-2-2-primefaces-5-spring-boot/
but for some reason, my root controller is returning raw text instead of the page. basically the views aren't loading.
@SpringBootApplication
public class MySpringAppApplication extends SpringBootServletInitializer {
private static final Logger logger = LoggerFactory.getLogger(MySpringAppApplication.class);
public static void main(String[] args) {
SpringApplication.run(MySpringAppApplication.class, args);
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(MySpringAppApplication.class, JsfInitializer.class);
}
// servlet to run jsf stuff
@Bean
public ServletRegistrationBean servletRegistrationBean() {
FacesServlet servlet = new FacesServlet();
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(servlet, "*.jsf");
return servletRegistrationBean;
}
}
and in my root controller, return "index" just returns that string
@RestController
public class RootController {
private MailSender mailSender;
@Autowired
RootController(MailSender mailSender) {
this.mailSender = mailSender;
}
// @ResponseBody --not needed with @RestController
@RequestMapping("/")
public String home() throws MessagingException {
// mailSender.send("franklin@gmail.com", "programming", "how are you on that project?");
return "index";
}
}
index.xhtml in in the WebContent dir
public class JsfInitializer implements ServletContextInitializer{
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
servletContext.setInitParameter("primefaces.CLIENT_SIDE_VALIDATION", "true");
servletContext.setInitParameter("javax.faces.PROJECT_STAGE", "Development");
}
}
and in faces.config:
<application>
<el-resolver>
org.springframework.web.jsf.el.SpringBeanFacesELResolver
</el-resolver>
</application>
no web.xml file