当前位置: 首页 > 知识库问答 >
问题:

Spring Boot Primefaces默认URL重定向

夹谷英杰
2023-03-14

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

有人可以举个例子如何在Spring Boot中配置它吗?

共有1个答案

周飞
2023-03-14

在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();
    }
}
 类似资料:
  • 我开始使用身份服务器4(在ASP. NET Core下)使用隐式流来保护Angular 2前端(到Web API服务)。 使用oidc-Client JS库,我可以成功地从示例的默认页面重定向到我的登录页面,让用户进行身份验证,然后重定向(通过 /connect/authorize)返回Angular站点的回调。 如果用户直接浏览到我的身份验证登录页面(而不是Angular主页),我就可以进行身份

  • 我已经看了下面的帖子。我仍然无法理解重定向URI的概念。 https://www.baeldung.com/spring-webclient-oauth2 https://docs.spring.io/spring-security/site/docs/5.0.7.RELEASE/reference/html/oauth2login-advanced.html#oauth2login-高级重定向终

  • 我已经这样配置了我的axios 在我的组件中,我作为 现在,上面的方法可以工作了,但是我想在不影响全局基本URL的情况下更改,这样在我的组件中,我就可以在没有APIendpoint的情况下简单地使用它 我已经试过了 我该怎么办?

  • 我在我的springBoot应用程序中添加了H2DB,用于单元测试目的。 应用中测试。我刚刚添加的属性: Spring数据源。名称=h2db spring.h2.console.enabled=true 它工作正常,节省了价值。 但它是如何工作的,我如何浏览这个数据库?

  • 我是微服务和Spring Boot的新手。我有几个Spring Cloud微服务,它有一个运行在8080端口上的Zuul网关。 提前道谢!

  • 我正在尝试将Spring Security与数据库一起使用,在遵循一个示例之后,我可以登录(调用<code>onAuthenticationSuccess</code>),但我没有被重定向到默认页面,而是得到了一个空文件下载。我希望重定向到默认页面 安全配置类: