在操作类中传递隐藏字段
<s:iterator value="categoryList">
<s:url id="category" action="/editProduct.action"/>
<s:a href="%{category}">
<s:property value="name"/>
</s:a>
<s:hidden name = "categoryId" id = "categoryId" value = "<s:property value='name'/" />
</s:iterator
问题:
我有一个可单击的类别列表。每个类别都有一个唯一的 ID。问题是,当用户单击列表中的类别时,categoryId 将传入 editProduct 操作类
我两天来一直在寻找解决方案,请帮助我并定义完整的解决方案
<s:iterator value="categoryList">
<s:url id="category" action="/editProduct.action"/>
<s:a href="%{category}">
<s:property value="name"/>
</s:a>
<s:hidden name = "categoryId" id = "categoryId" value = "<s:property value='name'/" />
</s:iterator
Problem:
I have a list of categories which are click able. Every category has a unique ID. Problem is that when user click on the category from list then categoryId will pass in editProduct action class
I am searching its solution from two days please help me and define the complete solution
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能像那样嵌套 JSP 标签。
然而,这是没有意义的——如果它不是表单,为什么要将
categoryId
放入隐藏的表单字段中?您不是在提交表单,而是在单击链接。将
categoryId
作为参数放入 URL 中。请注意,除非“名称”实际上非常类似于 ID,否则将其用作主键可能不是一个好主意。
在继续进行更多操作之前,您可能需要先了解一些 HTML 和 Web 应用程序基础知识;从长远来看,它会节省您的时间。
You can't nest JSP tags like that.
This, however, makes no sense--if it's not a form, why would you put the
categoryId
into a hidden form field? You're not submitting a form, you're clicking a link.Put the
categoryId
into the URL as a parameter.Note that unless "name" is actually something very ID-like, it's probably a bad idea to use it as a primary key.
You may want to go over some HTML and web app basics before proceeding too much further; it will save you time in the long run.