如何从 JSP 文件中获取源名称并将其添加到 img src 中?
我正在使用 MVC 而不是 Spring 制作在线书店 ShoppingMall。
我得到了 DAO 文件、Servlet 文件和 JSP 文件。 ProductRegisterAction.java(servelt) / ProductDAO.java / ProductRegister.jsp
我想注册图像,但有问题。我的图像位于文件夹“/images/CATEGORYNAME/”中 (不是 CATEGORYNAME、人文学科等等。请参见图片)
无论如何,我通过选择选项从 JSP 文件表单中获取了 CATEGORYNAME。我如何将此值赋予 Servlet 文件?
这是servlet 文件。
CategoryVO catevo = new CategoryVO();
String cate_name = mtrequest.getParameter("cate_name");
catevo.setCate_name(cate_name);
cate_name = mtrequest.getParameter("cate_name");
ServletContext svlCtx = session.getServletContext();
String uploadFileDir = svlCtx.getRealPath("/images/product"+cate_name);
这是 JSP 文件。
<form name="prodInputFrm"
action="<%= request.getContextPath()%>/product/admin/productRegister.book"
method="POST"
enctype="multipart/form-data">
<table id="tblProdInput" style="width: 80%;">
...
<tr>
<td width="25%" class="prodInputName" style="padding-top: 10px;">CATEGORY</td>
<td width="75%" align="left" style="padding-top: 10px;">
<select name="fk_cate_num" class="infoData">
<option value="">SELECT CATEGORY</option>
<c:forEach var="map" items="${requestScope.categoryList}">
<option value="${map.pk_cate_num}">${map.cate_name}</option>
</c:forEach>
</select>
</td>
</tr>
I'm making Online bookstore ShoppingMall with MVC not Spring.
I got DAO file and Servlet file and JSP file.
ProductRegisterAction.java(servelt) / ProductDAO.java / productRegister.jsp
I want to register image but I have problem. My images are in folder '/images/CATEGORYNAME/'
(not CATEGORYNAME, humanities, and so etc. See image please)
Anyway, I got CATEGORYNAME from JSP file form with select option. how can i give this values to Servlet file?
This is servlet file.
CategoryVO catevo = new CategoryVO();
String cate_name = mtrequest.getParameter("cate_name");
catevo.setCate_name(cate_name);
cate_name = mtrequest.getParameter("cate_name");
ServletContext svlCtx = session.getServletContext();
String uploadFileDir = svlCtx.getRealPath("/images/product"+cate_name);
And this is JSP file.
<form name="prodInputFrm"
action="<%= request.getContextPath()%>/product/admin/productRegister.book"
method="POST"
enctype="multipart/form-data">
<table id="tblProdInput" style="width: 80%;">
...
<tr>
<td width="25%" class="prodInputName" style="padding-top: 10px;">CATEGORY</td>
<td width="75%" align="left" style="padding-top: 10px;">
<select name="fk_cate_num" class="infoData">
<option value="">SELECT CATEGORY</option>
<c:forEach var="map" items="${requestScope.categoryList}">
<option value="${map.pk_cate_num}">${map.cate_name}</option>
</c:forEach>
</select>
</td>
</tr>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论