我已经设置了Spring Boot + Primefaces +嵌入式Tomcat项目,到目前为止我很满意,特别是识别Spring bean和服务的facelets (SpringBeanFacesELResolver)。现在我要配置应用程序,让基础URL转换为faces的基础URL。例如:http://localhost:8080/重定向到http://localhost:8080/index.xhtml
有人能提供一个如何在Spring Boot中配置这个的例子吗?
借助https://github.com/benneq我找到解决办法了…我定义了新的@Controller Spring Bean和一个方法,它将空白路径重定向到index.xhtml:
@Controller
public class RedirectController {
private static final Logger LOG = LoggerFactory
.getLogger(RedirectController.class);
@RequestMapping(value = "", method = RequestMethod.GET)
public String baseUrlRedirect(HttpServletRequest request,
HttpServletResponse httpServletResponse) {
return "redirect:" + request.getRequestURL().append("index.xhtml").toString();
}
}