网页的<title> 部分与后台数据库绑定

动态生成网页标题与数据绑定

前台页面:

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title><%=newtitle%></title>


后台页面:

 

   
//定义字段
 public string newtitle;
      protected void Page_Load(object sender, EventArgs e)
    {
      

        SqlConnection con = new SqlConnection();
        string sql2 = "select TOP 20* from  table order by newdate DESC";

        SqlDataAdapter da2 = new SqlDataAdapter(sql2, con);

        DataSet ds2 = new DataSet();

        da2.Fill(ds2, "webinfo2");

        DataList2.DataSource = ds2;
        DataList2.DataKeyField = "id";
        DataBind();
        newtitle = "动态title";

    }


 

package book.library.dao; import book.library.beans.BookBeans; import book.library.util.DBCon; import java.sql.*; import java.util.ArrayList; import java.util.List; public class BookDAO { private Connection conn; public BookDAO() throws SQLException { this.conn = DBCon.getConnection(); } public void addBook(BookBeans book) throws SQLException { String sql = "INSERT INTO books (title, price, author, publisher, stock, modifiedStock) VALUES (?, ?, ?, ?, ?, ?)"; try (PreparedStatement pstmt = conn.prepareStatement(sql)) { pstmt.setString(1, book.getTitle()); pstmt.setDouble(2, book.getPrice()); pstmt.setString(3, book.getAuthor()); pstmt.setString(4, book.getPublisher()); pstmt.setInt(5, book.getStock()); pstmt.executeUpdate(); } } public void updateBook(BookBeans book) throws SQLException { String sql = "UPDATE books SET title = ?, price = ?, author = ?, publisher = ?, stock = ? WHERE id = ?"; try (PreparedStatement pstmt = conn.prepareStatement(sql)) { pstmt.setString(1, book.getTitle()); pstmt.setDouble(2, book.getPrice()); pstmt.setString(3, book.getAuthor()); pstmt.setString(4, book.getPublisher()); pstmt.setInt(5, book.getStock()); pstmt.setInt(6, book.getId()); pstmt.executeUpdate(); } } public void deleteBook(int id) throws SQLException { String sql = "DELETE FROM books WHERE id = ?"; try (PreparedStatement pstmt = conn.prepareStatement(sql)) { pstmt.setInt(1, id); pstmt.executeUpdate(); } } public List<BookBeans> getAllBooks() throws SQLException { List<BookBeans> books = new ArrayList<>(); String sql = "SELECT * FROM books"; try (Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(sql)) { while (rs.next()) { BookBeans book = new BookBeans(); book.setId(rs.getInt("id")); book.setTitle(rs.getString("title")); book.setPrice(rs.getDouble("price")); book.setAuthor(rs.getString("author")); book.setPublisher(rs.getString("publisher")); book.setStock(rs.getInt("stock")); books.add(book); } } return books; } } 这是后台代码,请修改。<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="https://jakarta.ee/xml/ns/jakartaee/jstl/core" %> <!DOCTYPE html> <html> <head> <title>图书信息展示</title> </head> <body> <h1>图书信息</h1> <table border="1"> <tr> <th>图书名称</th> <th>图书价格</th> <th>图书作者</th> <th>出版社</th> <th>存放数量</th> <th>修改数量</th> <th>删除</th> </tr> <c:forEach var="book" items="${books}"> <tr> <td>${book.title}</td> <td>${book.price}</td> <td>${book.author}</td> <td>${book.publisher}</td> <td>${book.stock}</td> <td> <a href="book?id=${book.id}">修改</a> </td> <td> <a href="delete?id=${book.id}">删除</a> </td> </tr> </c:forEach> </table> <a href="book.jsp">添加图书信息</a> </body> </html>这是前台代码,请修改。
05-12
<div class="layui-card-body layui-table-body layui-table-main"> <table class="layui-table layui-form" id="demo" lay-data="page:true" lay-filter="test"> <thead> <tr style="height:30px;"> <th lay-data="{field:'id',sort:true,width:80,fixed:'left'}">No.</th> <th lay-data="{field:'plant',fixed:'left'}">厂别</th> <th lay-data="{field:'kubie'}">库别</th> <th lay-data="{field:'category'}">出货类别</th> <th lay-data="{field:'so_number'}">票号</th> <th lay-data="{field:'pallet_number'}">板号</th> <th lay-data="{field:'liaohao'}">料号</th> <th lay-data="{field:'name'}">品名</th> <th lay-data="{field:'demand'}">需求数量</th> <th lay-data="{field:'prepared_qty'}">备料数量</th> <th lay-data="{field:'creator'}">创建人</th> <th lay-data="{field:'create_time',width:160,fixed:'right'}">上传时间</th> </tr> </thead> <tbody> <?php $i=0;$j=$pagenum;foreach($dataArr as $w){$i++;?> <tr> <td><?= $i ?></td> <td><?= $w['plant'] ?></td> <td><?= $w['kubie'] ?></td> <td><?= $w['category'] ?></td> <td><?= $w['so_number'] ?></td> <td><?= $w['pallet_number'] ?></td> <td><?= $w['material'] ?></td> <td><?= $w['name'] ?></td> <td><?= $w['demand'] ?></td> <td><?= $w['prepared_qty'] ?></td> <td><?= $w['creator'] ?></td> <td><?= $w['create_time'] ?></td> </tr> <?php $j++;} ?> </tbody> </table> </div>如上表格会有N行,请在每行设置一个点击的功能或者添加一个编辑的按钮,点击后,可以读取当行的category类型,当category为不良品时,弹出当行文本框输入备料数量prepared_qty,并可以剪辑提交将prepared_qty备料数量更新到后台数据库;当category为非不良品时,弹出多行文本框,可刷入多个箱号,prepared_qty备料数量等于箱号*10,刷入OK后,点击提交将prepared_qty备料数量更新到后台数据库
最新发布
11-20
<div class="layui-card-body layui-table-body layui-table-main"> <table class="layui-table layui-form" id="demo" lay-data="page:true" lay-filter="test"> <thead> <tr style="height:30px;"> <th lay-data="{field:'id',sort:true,width:80,fixed:'left'}">No.</th> <th lay-data="{field:'plant',fixed:'left'}">厂别</th> <th lay-data="{field:'kubie'}">库别</th> <th lay-data="{field:'category'}">出货类别</th> <th lay-data="{field:'so_number'}">票号</th> <th lay-data="{field:'pallet_number'}">板号</th> <th lay-data="{field:'liaohao'}">料号</th> <th lay-data="{field:'name'}">品名</th> <th lay-data="{field:'demand'}">需求数量</th> <th lay-data="{field:'prepared_qty'}">备料数量</th> <th lay-data="{field:'creator'}">创建人</th> <th lay-data="{field:'create_time',width:160,fixed:'right'}">上传时间</th> </tr> </thead> <tbody> <?php $i=0;$j=$pagenum;foreach($dataArr as $w){$i++;?> <tr> <td><?= $i ?></td> <td><?= $w['plant'] ?></td> <td><?= $w['kubie'] ?></td> <td><?= $w['category'] ?></td> <td><?= $w['so_number'] ?></td> <td><?= $w['pallet_number'] ?></td> <td><?= $w['material'] ?></td> <td><?= $w['name'] ?></td> <td><?= $w['demand'] ?></td> <td><?= $w['prepared_qty'] ?></td> <td><?= $w['creator'] ?></td> <td><?= $w['create_time'] ?></td> </tr> <?php $j++;} ?> </tbody> </table> </div>表格第一列每元格里添加一个编辑按钮,点击后按钮,读取当前行的category为不良品时,弹出单行文本框输入备料数量,并将值提交到后台数据库;当category为非不良品时,弹出textarea多行文本框刷入箱号,如刷入5个箱号时,自动计算备料数量prepared_qty等于5*10,提交后将值更新到数据库
11-19
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值