Invalid location of tag (form)

今天遇到了个问题,导入的公司的web项目,很多jsp文件中说第一个form没有定义,或者位置不对。从代码上看得出是有定义的,然后看看myeclipse里面的提示,是Invalid location of tag (form) ,于是上网查了下,得出的结论都是:

MyEclipse提示正常了,原因在此:
<form></form>不能写到<table></table>里面!

所以,我把没必要的form标签去掉就可以了

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="java.sql.*" %> <!DOCTYPE html> <html> <head> <title>电影管理</title> <script> // 删除电影记录的函数 function deleteMovie(movieId) { if (confirm('确定要删除这部电影吗?')) { // 创建表单进行删除操作 var form = document.createElement('form'); form.method = 'post'; form.action = 'deleteMovie.jsp'; var input = document.createElement('input'); input.type = 'hidden'; input.name = 'id'; input.value = movieId; form.appendChild(input); document.body.appendChild(form); form.submit(); } } // 添加电影跳转 function addMovie() { window.location.href = 'movieAdd.jsp'; } </script> </head> <body> <h1 align="center">电影列表</h1> <!-- 添加电影按钮 --> <div align="center" style="margin-bottom: 15px;"> <button onclick="addMovie()">添加新电影</button> </div> <% Connection con = null; Statement stmt = null; ResultSet rs = null; try { Class.forName("com.mysql.cj.jdbc.Driver"); } catch(Exception e) { out.print(e); } String url = "jdbc:mysql://localhost:3306/movie"; String user = "root"; String pass = "123456"; String moviename = request.getParameter("mvname"); String strSql = "SELECT * FROM movies"; %> <div align="center"> <table border="1"> <tr> <th width="50">id</th> <th width="200">title</th> <th width="150">director</th> <th width="300">description</th> <th width="150">duration</th> <th width="50">编辑</th> <th width="50">删除</th> </tr> <% try { con = DriverManager.getConnection(url, user, pass); stmt = con.createStatement(); rs = stmt.executeQuery(strSql); while(rs.next()) { out.print("<tr>"); out.print("<td>" + rs.getString("id") + "</td>"); out.print("<td>" + rs.getString("title") + "</td>"); out.print("<td>" + rs.getString("director") + "</td>"); out.print("<td>" + rs.getString("description") + "</td>"); out.print("<td>" + rs.getString("duration") + "</td>"); // 编辑按钮 out.print("<td><a href='movieEdit.jsp?id=" + rs.getString("id") + "'>编辑</a></td>"); // 删除按钮 out.print("<td><a href='javascript:void(0);' onclick='deleteMovie(" + rs.getString("id") + ")'>删除</a></td>"); out.print("</tr>"); } con.close(); } catch(SQLException e) { out.print(e); } finally { // 关闭资源 try { if (rs != null) rs.close(); } catch (Exception e) {} try { if (stmt != null) stmt.close(); } catch (Exception e) {} try { if (con != null) con.close(); } catch (Exception e) {} } %> </table> </div> <br/> <div align="center"> <form action="searchmovie.jsp" method="post"> 请输入电影名:<input type="text" name="mvname"><input type="submit" value="查询"> <a href="adminIndex.jsp">返回</a> </form> </div> </body> </html> 能否根据这个movieManage.jsp仿写一个scheduleManage.jsp,数据库schedules表中有6列,id,movie_id,start_time,end_time ,theater_id,price
最新发布
12-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值