Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/337.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

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
Java 如何将特定的图像值转发到servlet_Java_Jsp_Jakarta Ee_Jstl - Fatal编程技术网

Java 如何将特定的图像值转发到servlet

Java 如何将特定的图像值转发到servlet,java,jsp,jakarta-ee,jstl,Java,Jsp,Jakarta Ee,Jstl,//我的Jsp代码 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <html> <head> </head> <body> <h1>Welcome to Loader</h1> <c:forEach var="sampleMap" items="${MAP}"> <center><a href="br

//我的Jsp代码

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
</head>
<body>
<h1>Welcome to Loader</h1>
<c:forEach var="sampleMap" items="${MAP}">
<center><a href="brand1.jsp">
<img src="<%=request.getContextPath()%>/logo/${sampleMap.value}"></a>
<c:set var="brand" value="${sampleMap.value}" scope="session"/>
</center>
</c:forEach>
</body>
</html>

欢迎来到加载器
我使用Servlet从数据库中获取图像并存储在地图中,使用for:each在jsp中获取图像并放入a href标记,这样我们就可以像图像按钮一样工作

但我的问题是,我希望在单击某个特定图像并将其删除时,将图像对应的值发送到Servlet

<c:set var="brand" value="${sampleMap.value}" scope="session"/>

上述代码始终发送最后获取的值

Plzz帮助


<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
</head>
<body>
<h1>Welcome to Loader</h1>
<c:forEach var="sampleMap" items="${MAP}">
<center><a href="brand1.jsp?imagevalue=${sampleMap.value}">
<img src="<%=request.getContextPath()%>/logo/${sampleMap.value}"></a>
</center>
</c:forEach>
</body>
</html>
欢迎来到加载器

并使用
request.getParameter(“iamgeValue”)
在servlet中

您可以通过将href的url中的值作为参数来实现:

<a href="brand1.jsp?image=${sampleMap.value}">

把它放在href.please.TY@developerjk的url中。你的语法是错误的。使用EL与在Java中连接字符串不同。不是
,而是
。您不会使用
request.getAttribute(“iamgeValue”)
而是
request.getParameter(“iamgeValue”)
。完成!谢谢你宝贵的帮助和时间,先生。
request.getParameter("image");