gpt4 book ai didi

jakarta-ee - 用 Servlet 3.0 注释替换 context-param 元素

转载 作者:行者123 更新时间:2023-12-04 03:23:01 24 4
gpt4 key购买 nike

给定:一个 Java EE 5 web 应用程序,它有一个 web.xml,它有一个像

<context-param>
<description>c</description>
<param-name>a</param-name>
<param-value>b</param-value>
</context-param>

我需要做什么才能将该上下文参数规范移动到基于注释的策略中。

最佳答案

您可以找到所有 javax.servlet javax.servlet.annotation 中的注释套餐概要:

  • @HandlesTypes This annotation is used to declare the class types that a ServletContainerInitializer can handle.
  • @HttpConstraint This annotation is used within the ServletSecurity annotation to represent the security constraints to be applied to all HTTP protocol methods for which a corresponding HttpMethodConstraint element does NOT occur within the ServletSecurity annotation.
  • @HttpMethodConstraint This annotation is used within the ServletSecurity annotation to represent security constraints on specific HTTP protocol messages.
  • @MultipartConfig Annotation that may be specified on a Servlet class, indicating that instances of the Servlet expect requests that conform to the multipart/form-data MIME type.
  • @ServletSecurity This annotation is used on a Servlet implementation class to specify security constraints to be enforced by a Servlet container on HTTP protocol messages.
  • @WebFilter Annotation used to declare a servlet Filter.
  • @WebInitParam This annotation is used on a Servlet or Filter implementation class to specify an initialization parameter.
  • @WebListener This annotation is used to declare a WebListener.
  • @WebServlet Annotation used to declare a servlet.


你看,没有什么比 @WebContextParam .这也或多或少有意义;你会/可以在什么样的类(class)上设置它?

一些依赖于上下文参数的基于 Servlet 的框架,例如 JSF,也允许通过 JNDI 设置其中的一些。你可能想研究一下。或者如果它涉及本土代码,那么我会看看 @WebInitParam对您来说不是更可行的选择。

关于jakarta-ee - 用 Servlet 3.0 注释替换 context-param 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7970051/

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