Tag: embedded tomcat 8

在spring boot 2.0.0中设置jvmRoute

对于粘性会话,我需要设置嵌入式tomcat的jvmRoute。 实际上只有一个 System.setProperty(“jvmRoute”, “node1”); 是必需的,但我想设置一个via application.properties可配置属性。 我不知道如何以及何时使用@Value注释属性进行设置。 使用@PostConstruct,如此处所述,它不起作用(至少不在spring boot 2.0.0.RELEASE中) 我到目前为止找到的唯一方法是 @Component public class TomcatInitializer implements ApplicationListener { @Value(“${tomcat.jvmroute}”) private String jvmRoute; @Override public void onApplicationEvent(final ServletWebServerInitializedEvent event) { final WebServer ws = event.getApplicationContext().getWebServer(); if (ws instanceof TomcatWebServer) { final TomcatWebServer tws = (TomcatWebServer) ws; final Context context = (Context) tws.getTomcat().getHost().findChildren()[0]; context.getManager().getSessionIdGenerator().setJvmRoute(jvmRoute); } } } […]

如何将子域转换为嵌入式Tomcat 8和Spring引导的路径

如何将子域重写到路径? 例: foo.bar .example.com – > example.com / foo / bar 或者更好(反向文件夹): foo.bar .example.com – > example.com / bar / foo 请求foo.bar .example.com应该在/ src / main / resources / static / bar / foo /index.html中发送文件。 使用Apache2,它由mod_rewrite完成。 我找到了有关使用Tomcat 8重写的文档,但问题是在哪里使用spring boot放置这些文件? 更新 我尝试使用UrlRewriteFilter ,但似乎无法使用正则表达式替换在域路径中定义规则。 这是我的配置: Maven依赖: org.tuckey urlrewritefilter 4.0.3 Spring Java Config注册Servletfilter: @Configuration @ComponentScan @EnableAutoConfiguration public class […]

servlet不会将会话属性转发给jsp

使用嵌入式tomcat,此代码有效: Servlet : String test = “test”; request.setAttribute(“test”, test); request.getRequestDispatcher(“/index.jsp”).forward(request, response); JSP : 它设置属性test ,然后在servlet /example的jsp页面example.jsp上打印出来。 但是,如果我尝试在会话中设置属性,那么我得不到相同的结果,相反,我使用它时得到一个null : Servlet : String test = “test”; request.getSession().setAttribute(“test”, test); request.getRequestDispatcher(“/index.jsp”).forward(request, response); JSP :