簡體   English   中英

如何在jsp中獲取上下文參數值?

[英]How can i get context parameter value in jsp.?

  <context-param>
        <param-name>productSearchRPP</param-name>
        <param-value>8</param-value>
    </context-param>

我想在products.jsp頁面中獲得productSearchRPP的價值

pageContext.getServletContext().getInitParameter("key");

這是您在JSP中獲取上下文參數值的方法。 在JSTL中你可以這樣得到它

${pageContext.servletContext}

要么

${applicationScope.attributeName}
${initParam['productSearchRPP']}

或者,進入scriptlet

<%= pageContext.getServletContext().getInitParameter("productSearchRPP") %>

即使你可以在你的jsp中試試這個。

ServletContext context = pageContext.getServletContext();
com = context.getInitParameter("com");

並使用jstl你可以使用。

${initParam['theStringIWant']}

嘗試這個:

application.getInitParameter("productSearchRPP")
 application.getServletContext().getInitParameter("productSearchRPP");

用它來獲得所需的結果

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM