jsp页面如何获取指定值传到后台

本文介绍了一种从数据库查询特定ID值的方法,并详细解释了如何在前端页面通过点击事件传递这些ID值到后台进行进一步处理的技术细节。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. 在一个页面中如果你要获取他的值,你首先在sql中查出他的值
  2. 比如我就想在点击查看的时候获得一个id值
  3. 我首先就要在这个页面执行的时候,查出这个id值
    在这里插入图片描述
 select
        temp.serialNumber AS "bzDeceased.serialNumber",
        temp.actualName AS "bzDeceased.actualName",
        temp.deceId AS "bzDeceased.id",  --这个是我现在需要获取的值,所以在这个页面执行sql的时候我查出来了
        temp.no as  "createBy.no",
        temp.totalPrice as "allTotalPrice",
        temp.beginFuneralTime as "bzYsgl.beginFuneralTime"
        from
        (
        SELECT
        dece.serial_number AS "serialNumber",
        dece.actual_name AS "actualName",
        dece.id as "deceId",
        ysgl.begin_funeral_time AS "beginFuneralTime",
        sysUser.no AS "no",
        SUM(rela.unit_price*rela.prod_count)  AS "totalPrice"
        FROM
        bz_consumelist_project_relation rela
        left join bz_negotiation_consumelist nego on nego.id = rela.consumelist_id and nego.del_flag = '0'
        left join bz_deceased dece on dece.id = nego.deceased_id and dece.del_flag = '0'
        left join sys_user sysUser on sysUser.id = dece.create_by and sysUser.del_flag = '0'
        join bz_ysgl ysgl on ysgl.bz_deceased_id = dece.id  and ysgl.del_flag = '0'
        where
        rela.del_flag = '0'
        AND rela.`status` != '5'
        AND rela.`status`!= '1'
        GROUP BY dece.serial_number,dece.actual_name,sysUser.no
        ) temp
        where temp.totalPrice > 20000
        <if test="bzYsgl != null">
            <choose>
                <when test="bzYsgl.beginBzYsglDate != null and bzYsgl.beginBzYsglDate != '' and bzYsgl.endBzYsglDate != null and bzYsgl.endBzYsglDate != ''">
                    and (temp.beginFuneralTime between  #{bzYsgl.beginBzYsglDate} and #{bzYsgl.endBzYsglDate})
                </when>
                <otherwise>
                    <if test="bzYsgl.beginBzYsglDate != null and bzYsgl.beginBzYsglDate != ''">
                        AND temp.beginFuneralTime = #{bzYsgl.beginBzYsglDate}
                    </if>
                    <if test="bzYsgl.endBzYsglDate != null and bzYsgl.endBzYsglDate != ''">
                        AND temp.beginFuneralTime = #{bzYsgl.endBzYsglDate}
                    </if>
                </otherwise>
            </choose>
        </if>
        <if test="bzDeceased != null">
            <if test="bzDeceased.serialNumber != null and bzDeceased.serialNumber != ''">
                and temp.serialNumber like
                concat('%',#{bzDeceased.serialNumber},'%')
            </if>
        </if>
        GROUP BY temp.serialNumber,temp.actualName
        ORDER BY temp.no
  1. 页面已经有我需要那个id值的时候,我就在点击查看的时候传入这个值即可
	<td>
	<a href="javascript:void(0);"onclick="showDetailBusinessTwentyThousand('${bzConsumelistProjectRelation.bzDeceased.id}')">查看</a> //因为这是一个list集合条数据的值是不一样的,所以要找到对应的链接,获取到他得值,然后传到onclick点击方法上面接收,然后拼到路径上,传到后台即可
</td>

	<td>
					<a href="javascript:void(0);" onclick="showDetailBusinessTwentyThousand('${bzConsumelistProjectRelation.bzDeceased.id}','${bzConsumelistProjectRelation.createBy.id}')">查看</a>
				</td>//传两个id
   //显示相应类型的详细信息
        function showDetail(bzdeceasedId) {//bzdeceasedId 这个就是定义接收的id值
			top.$.jBox.open("iframe:${ctx}/bz/consumelistproject/bzConsumelistProjectRelation/showDetail?bzdeceasedId="+bzdeceasedId,
					"两万详细查询",$(top.document).width()/1.3,$(top.document).height()/1.4,{
						buttons: {"关闭": true},
						bottomText: "",
						submit: function (v, h, f) {
							if (v == 'ok') {
							}
						}, closed: function () {
							//window.location.href = "${ctx}/bz/consumelistproject/bzConsumelistProjectRelation/queryConsume";
						}
					});
		}

	//显示相应类型的详细信息
		function showDetailBusinessTwentyThousand(deceasedId,creaeById) {
			top.$.jBox.open("iframe:${ctx}/bz/consumelistproject/bzConsumelistProjectRelation/showDetailBusinessTwentyThousand?deceasedId="+deceasedId+"&creaeById="+creaeById,
					"业务员两万详细查询",$(top.document).width()/1.3,$(top.document).height()/1.4,{
						buttons: {"关闭": true},
						bottomText: "",
						submit: function (v, h, f) {
							if (v == 'ok') {
							}
						}, closed: function () {
							//window.location.href = "${ctx}/bz/consumelistproject/bzConsumelistProjectRelation/queryConsume";
						}
					});//传两个id
		}
model.addAttribute("bzDeceaseds",bzDeceaseds);这是在后台传的对象到页面,前台可以通过对象bzDeceaseds点来获取值
在xml查出对应的id在前端传过来后台获取查询
id=${bzDeceaseds.id}前端要对应后台model传的对象值获取
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Java中的战斗机

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值