码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • jsp的<a>超连接传值


    目录

    jsp部分摘要

    Servlet部分摘要

    CommunityEventRegistrationService

    CommunityEventRegistrationDao


    jsp部分摘要

    1. <c:forEach items="${sessionScope.CommunityEventRegistrationList}" var="cer">
    2. <form class="form-horizontal" action="/CommunityEventRegistrationDelete" method="post">
    3. <a class="btn btn-danger" href="/CommunityEventRegistrationDelete?id=1&username=${cer.username }">
    4. 删除
    5. </a>
    6. </form>
    7. </c:forEach>

    其中href="/CommunityEventRegistrationDelete?id=1&username=${cer.username }"

    CommunityEventRegistrationDelete为指向的Servlet

    传两个值,一个是id,一个是username。【这里展示的是两种不同形式】

    Servlet部分摘要

    1. int id = Integer.parseInt(request.getParameter("id"));
    2. String name = request.getParameter("username");
    3. boolean isSuccess = cerService.update(communityeventregistration,s1.substring(7),id,name);
    4. if(isSuccess) {
    5. request.setAttribute("msg", "删除成功!可刷新查看!");
    6. }else {
    7. request.setAttribute("failMsg", "删除失败!");
    8. }

    jsp传值过来后,Servlet就用request.getParameter("???");来接收

    然后id,name可以这样

    boolean isSuccess = cerService.update(communityeventregistration,s1.substring(7),id,name);

    塞在后面,传值进Service类使用方法进入后续操作

    CommunityEventRegistrationService

    1. public class CommunityEventRegistrationService{
    2. private CommunityEventRegistrationDao cerDao = new CommunityEventRegistrationDao();
    3. public boolean update(CommunityEventRegistration communityeventregistration,String phone,int id,String name) {
    4. try {
    5. cerDao.update(communityeventregistration, phone, id, name);
    6. return true;
    7. } catch (SQLException e) {
    8. // TODO Auto-generated catch block
    9. e.printStackTrace();
    10. return false;
    11. }
    12. }
    13. }

    CommunityEventRegistrationDao

    1. public class CommunityEventRegistrationDao {
    2. public void update(CommunityEventRegistration communityeventregistration, String phone,int id, String username) throws SQLException {
    3. QueryRunner r = new QueryRunner(DataSourceUtils.getDataSource());
    4. System.out.println("update在此1");
    5. if(id==1){
    6. System.out.println("update在此2");
    7. String sql = "update `communityeventregistration` set yoga='-----' where phone = ? and username=? and yoga= '√'";
    8. r.update(sql,phone,username);
    9. }
    10. }
    11. }

  • 相关阅读:
    【python之django1.11框架四】模型层(ORM语法)的介绍
    什么?MySQL的等值查询竟然出错了??
    让 GPT-4 来修复 Golang “数据竞争”问题 - 每天5分钟玩转 GPT 编程系列(6)
    22.(地图工具篇)geoserver点服务图层SLD样式效果1
    FPGA零基础学习:图像显示系统设计
    【LeetCode每日一题】【单调栈】907. 子数组的最小值之和 Java实现
    【报错】springboot3启动报错
    python时间戳获取、时间比较、时间推算
    Linux项目自动化构建工具--make&Makefile
    MySQL的事务使用
  • 原文地址:https://blog.csdn.net/weixin_45528773/article/details/134022767
  • 最新文章
  • 【JVM】编译执行与解释执行的区别是什么?JVM 使用哪种方式?
    用 Hashids 优雅解决 C 端自增 ID 暴露问题
    V8引擎 精品漫游指南--Ignition篇(上) 指令 栈帧 槽位 调用约定 内存布局 基础内容
    LLVM Pass快速入门(四):代码插桩
    milkup:桌面端 markdown AI续写和即时渲染
    基于项目工程构建SBOM(软件物料清单)的研究
    鸿蒙应用开发UI基础第二节:鸿蒙应用程序框架核心解析与实操
    .NET 中如何快速实现 List 集合去重?
    扣子Coze实战:从0到1打造抖音+小红书热点监控智能体
    浅谈数据访问层
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
小工具 小游戏
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1

京公网安备 11010502049817号