我试图在同一页面中显示输入的值,当用户在字段中输入值并提交时,这些值应保存数据库并应显示在同一 jsp 页面中。我试过了,这些值存储在数据库中,但没有显示在同一页面上,但是,它显示空值,然后在执行提交操作时 div 消失,我在数据库中使用存储过程这是jsp页面:<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Stored Procedure</title><script>function show(){ document.stp.submit(); document.getElementById("display").style.display="block";}</script></head><body><form name="stp" action="STP" >ID:<input type="text" name="ID"><br> Name:<input type="text" name="Name"><br>Branch:<input type="text" name="Branch"><br>MobileNo:<input type="tel" name="Mobile"><br><input type="button" value="Submit" onclick="show()"></form><div id="display" style="display:none">Id:<%= request.getAttribute("id") %><br>Name:<%= request.getAttribute("name") %><br>Branch:<%= request.getAttribute("branch") %><br>MobileNo:<%= request.getAttribute("mobile") %><br></div></body></html>这是servlet代码:package task;import java.io.IOException;import java.sql.CallableStatement;import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException;import javax.servlet.ServletException;import javax.servlet.annotation.WebServlet;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;@WebServlet("/STP")public class STP extends HttpServlet { static { try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
添加回答
举报
0/150
提交
取消