gpt4 book ai didi

servlets - Dropwizard:设置 servlet 上下文参数

转载 作者:行者123 更新时间:2023-12-05 00:32:38 24 4
gpt4 key购买 nike

给定以下 web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<filter>
<filter-name>Guice Filter</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Guice Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>com.foo.JerseyContextListener</listener-class>
</listener>
<context-param>
<param-name>module</param-name>
<param-value>com.foo.MainModule</param-value>
</context-param>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>

如何告诉 DropWizard 将“模块”servlet 上下文参数设置为“com.foo.MainModule”?
Configuration.getHttpConfiguration().getContextParameters()总是返回一个空列表。我们应该扩展这个类吗?

最佳答案

您可以在配置文件中设置它:

- http:
- contextParameters:
- module: com.foo.MainModule

关于servlets - Dropwizard:设置 servlet 上下文参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13259672/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com