码农知识堂 - 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. }

  • 相关阅读:
    使用 PostgreSQL 16.1 + Citus 12.1 作为多个微服务的分布式 Sharding 存储后端
    【MySQL集群一】CentOS 7上搭建MySQL集群:一主一从、多主多从
    利用对数器验证算法代码程序
    Docker介绍
    说一下 ArrayDeque 和 LinkedList 的区别?
    工业4.0 管理壳学习笔记(6)-数字铭牌
    1458_树莓派安装使用aria2
    让 K8s 更简单!8款你不得不知的 AI 工具-Part 2
    西门子PLC编程之模拟量输入具体实现方法
    【数据结构回顾】
  • 原文地址:https://blog.csdn.net/weixin_45528773/article/details/134022767
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号