【问题标题】:Spring Boot + Primefaces default URL redirectionSpring Boot + Primefaces 默认 URL 重定向
【发布时间】:2015-08-08 04:19:48
【问题描述】:

我已经设置了 Spring Boot + Primefaces + 嵌入式 Tomcat 项目,到目前为止我很满意,尤其是识别 Spring Bean 和服务 (SpringBeanFacesELResolver) 的 facelets。 现在我想配置应用程序,以便基本 URL 将转换为面孔基本 URL。 例如:http://localhost:8080/ 被重定向到http://localhost:8080/index.xhtml

谁能提供一个示例如何在 Spring Boot 中进行配置?

【问题讨论】:

  • 这个问题有相当多的歧义,但是给出具体的例子,你基本上想在常规的web.xml 文件中实现与<welcome-file>index.xhtml</welcome-file> 相同的效果?
  • 是的,就是这样。我相信我在github.com/benneq 的帮助下找到了答案并将提供答案,但如果存在,欢迎您提供更好/更合适的解决方案。

标签: jsf tomcat primefaces spring-boot


【解决方案1】:

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();
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-11-27
    • 2018-05-19
    • 2021-07-03
    • 2016-05-06
    • 1970-01-01
    • 2018-09-21
    • 1970-01-01
    相关资源
    最近更新 更多