账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    springboot 在ServletRegistrationBean环节获取url和参数
    • 2020-01-01 00:00
    • 10
    83
    0

    想要实现转发代理,但是转发前要做url和参数的具体识别。

    通过smiley-http-proxy-servlet包实现了转发,但是github页面中没有给出如何获取具体url和参数的方式。
    当然作者说这实际上是反向代理,不是真正的转发代理,可能本身就不行吧。

    所以想问一下这可以实现吗?在controller之前获取识别并转发

    下面是简单配置:

    @Configuration  
    public class ForwardProxy {  
        @Bean  
        public ServletRegistrationBean proxyServletRegistration(){  
            ServletRegistrationBean registrationBean = new ServletRegistrationBean(new ProxyServlet(), "/\*");  
            Map<String, String> params = ImmutableMap.of("targetUri", "http://localhost:4444", "log", "true");  
            registrationBean.setInitParameters(params);  
            return registrationBean;  
        }
    }
    0
    打赏
    收藏
    点击回答
    您的回答被采纳后将获得:提问者悬赏的 10 元积分
        全部回答
    • 0
    • 黄昏老枪 普通会员 1楼
      { "error": "Failed to generate content." }
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部