Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法将init/Context参数直接调用到jsp页面中_Jsp_Servlets_Web.xml_Context Param - Fatal编程技术网

无法将init/Context参数直接调用到jsp页面中

无法将init/Context参数直接调用到jsp页面中,jsp,servlets,web.xml,context-param,Jsp,Servlets,Web.xml,Context Param,在下面的web应用程序结构中,我试图将init和上下文参数从web.xml页面放到jsp页面,而不使用servlet index.html: <html> <head> <meta charset="ISO-8859-1"> <title>Insert title here</title> </head> <body> <form action="action" method="get"> <a

在下面的web应用程序结构中,我试图将init和上下文参数从web.xml页面放到jsp页面,而不使用servlet

index.html:

<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="action" method="get">
<a href="home.jsp">clik here</a></form>
</body>
</html>
请告诉我哪里出错了

谢谢

您的URL模式和jsp名称似乎不匹配。在web.xml中更改它们


向我们显示您在浏览器中点击的url。我已将index.html中的“action”映射到home.jsp,clik me link将请求重定向到home.jsp。问题是没有读取参数:
<webapp>


<context-param>
<param-name>per1</param-name>
<param-value>val1</param-value>
</context-param>

<welcome-file>
index.jsp</welcome-file>

<servlet>
<servlet-name>abc</servlet-name>
<jsp-file>home.jsp</jsp-file>
<init-param>   
        <description>This is an init parameter example</description>   
        <param-name>InitParam</param-name>   
        <param-value>init param value</param-value>   
    </init-param>   
</servlet>

<servlet-mapping>
<servlet-name>abc</servlet-name>
<url-pattern>action</url-pattern>
</servlet-mapping>
<html>
<body>

 <%= application.getInitParameter("per1")%>
 <%= config.getInitParameter("InitParam") %>
  ${initParam.per1)
 </body>


 </html>
null null 
<servlet-name>abc</servlet-name>
<jsp-file>/home.jsp</jsp-file>
<init-param>   
        <description>This is an init parameter example</description>   
        <param-name>InitParam</param-name>   
        <param-value>init param value</param-value>   
    </init-param>   
</servlet>

<servlet-mapping>
<servlet-name>abc</servlet-name>
<url-pattern>/home.jsp</url-pattern>
</servlet-mapping>