EL表达式中的if.....else....使用方法

<c:choose>
    <c:when test="${userEntity.user_Authority_id == 'AAAAA'}"><!-- 如果 -->
        <td>修改,删除</td>
    </c:when>
    <c:when test="${userEntity.user_Authority_id == 'AAAcb'}"><!-- 如果 -->
        <td>修改,删除</td>
    </c:when>
    <c:otherwise> <!-- 否则 -->
                                    
    </c:otherwise>
</c:choose>

<c:if test="${var.index % 2 == 0}">
</c:if>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
如果插入 "152@qq.com" 出错,可能是因为在获取表单输入框的值时,没有正确处理特殊字符 "@"。在JSP,可以使用 EL 表达式的方式获取表单输入框的值,例如: ```jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page import="java.sql.*" %> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert Data</title> </head> <body> <h1>Insert Data</h1> <form action="insert.jsp" method="post"> <label for="phone">Phone:</label> <input type="text" name="phone" id="phone"> <br/><br/> <input type="submit" value="Insert"> </form> <% if(request.getMethod().equals("POST")){ String phone = request.getParameter("phone"); if(phone != null && !phone.equals("")) { try { // 导入JDBC驱动程序并建立数据库连接 Class.forName("com.mysql.jdbc.Driver"); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "password"); // 编写SQL语句并创建PreparedStatement对象 String sql = "INSERT INTO your_table (phone) VALUES (?)"; PreparedStatement pstmt = conn.prepareStatement(sql); // 设置参数值 pstmt.setString(1, "${param.phone}"); // 执行SQL语句并提交事务 pstmt.executeUpdate(); conn.commit(); // 关闭连接 pstmt.close(); conn.close(); out.println("Data inserted successfully!"); } catch (Exception e) { e.printStackTrace(); out.println("Error: " + e.getMessage()); } } else { out.println("Phone number cannot be empty!"); } } %> </body> </html> ``` 请注意,这里使用 `${param.phone}` 获取输入框的值,这样可以避免特殊字符的问题。另外,为了避免SQL注入攻击,建议使用参数化查询。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值