当前位置: 代码迷 >> Java Web开发 >> 过去台传值到后台action,不要from表单 单击分类时,获得分类Id,传到商品列表,根据分类显示商品
  详细解决方案

过去台传值到后台action,不要from表单 单击分类时,获得分类Id,传到商品列表,根据分类显示商品

热度:253   发布时间:2016-04-16 21:41:00.0
从前台传值到后台action,不要from表单 单击分类时,获得分类Id,传到商品列表,根据分类显示商品,
页面:

<div class="lefter">
        <div class="box">
            <h2>商品分类</h2>
            <dl>
            <c:if test="${list1!=null }">
             <c:forEach items="${list1}" var="types1" varStatus="status">            
    <c:if test="${types1.pid==0 }">
    <dt>${types1.name}</dt>
    <c:forEach var="types2" items="${list1}" varStatus="status">
    <c:if test="${types2.pid==types1.typeId}"> 
    <dd><a href="goods_goodsListF.action" target="_self" onclick="ff();">${types2.name}</a></dd>   
    </c:if>
    </c:forEach>
    </c:if>    
             </c:forEach>
        </c:if>          
            </dl>
        </div>
        </div>

action:

/*
 * 获取前台列表
 */
@SkipValidation
public String goodsListF() {
rows = 12;
Map<String, Object> map = new HashMap<String, Object>();
if (!(name == null || name.trim().equals("")))
map.put("name", "%" + name + "%");
map.put("typeId", typeId);
map.put("count", rows);
map.put("start", (page - 1) * rows);
//每页显示2条记录
//总记录数
int totalCount = goodsService.count(map);
//计算总页数
totalPage = (totalCount-1)/rows+1;
if(page<1){page=1;}
if(page>totalPage){page=totalPage;}
list = goodsService.findAll(map);
return "home_good";
}
/*

struts:
<action name="shoppcart_*" class="shoppcartAction" method="{1}">
<result name="Add">/front/shopping-result.jsp</result>
<result name="list">/front/shopping.jsp</result>
<result type="json" name="json">
<param name="root">list</param>
</result>
</action>
------解决思路----------------------



 window.location.href="分类.action?id=id"
------解决思路----------------------
在后台 写个action  result type = chian 直接转到 跳转到a页面的action 实在 不想这样直接ajax 请求然后 解析返回的数据。dom来动态操作。
  相关解决方案