即使在后端存储数据后仍保留文本框值 [英] To retain the textbox value even after the data stored in back-end

查看:62
本文介绍了即使在后端存储数据后仍保留文本框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JSP代码:



<%

String aref = request.getParameter( ArR);

尝试{

Class.forName(com.mysql.jdbc.Driver);

java.sql。 Connection con = DriverManager.getConnection(jdbc:mysql:// localhost:3306 / airproject,root,

root);

ResultSet rs;

语句st = con.createStatement();

System.out.println(插入演示值('+ aref +'));

st.executeUpdate(插入演示值('+ aref +'));

System.out.println(保存记录);

} catch(ClassNotFoundException e){

e.printStackTrace();

} catch(SQLException e){

e。 printStackTrace();

}

session.setAttribute(结果,注册成功);

response.sendRedirect(menu0。 jsp);

%>




HTML代码:






注册












这些代码在后端存储时没有问题。但是当它返回以形成我输入的值时,它应该保留。



提前谢谢



我尝试过:



JSP代码:



<%

String aref = request.getParameter(ArR);

try {

Class.forName(com.mysql.jdbc.Driver);

java.sql.Connection con = DriverManager.getConnection(jdbc:mysql:// localhost:3306 / airproject, root,

root);

ResultSet rs;

语句st = con.createStatement();

System.out.println(插入演示值('+ aref +'));

st.executeUpdate(插入演示值('+ aref + '));

System.out.println(保存记录);

} catch(ClassNotFoundException e){

e。 printStackTrace();

} catch(SQLException e){

e.printStackTrace();

}

s ession.setAttribute(结果,注册成功);

response.sendRedirect(menu0.jsp);

%>




HTML代码:






注册












这些代码在后端存储时没有问题。但当它返回以形成我输入的值时,它应该保留。



提前谢谢

JSP Code:

<%
String aref = request.getParameter("ArR");
try {
Class.forName("com.mysql.jdbc.Driver");
java.sql.Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/airproject", "root",
"root");
ResultSet rs;
Statement st = con.createStatement();
System.out.println("insert into demo values('" + aref + "')");
st.executeUpdate("insert into demo values('" + aref + "')");
System.out.println("Record Saved");
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
session.setAttribute("Result", "Registered successfully");
response.sendRedirect("menu0.jsp");
%>


HTML Code:



Registration






These code don't have problem in storing in the back-end. But when it return to back to form the value what i have enter, it should retain.

Thanks in advance

What I have tried:

JSP Code:

<%
String aref = request.getParameter("ArR");
try {
Class.forName("com.mysql.jdbc.Driver");
java.sql.Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/airproject", "root",
"root");
ResultSet rs;
Statement st = con.createStatement();
System.out.println("insert into demo values('" + aref + "')");
st.executeUpdate("insert into demo values('" + aref + "')");
System.out.println("Record Saved");
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
session.setAttribute("Result", "Registered successfully");
response.sendRedirect("menu0.jsp");
%>


HTML Code:



Registration






These code don't have problem in storing in the back-end. But when it return to back to form the value what i have enter, it should retain.

Thanks in advance

推荐答案

您必须引入具有更高范围的变量。像类成员(首选)或类似值列表的全局存储。可以存储为cookie吗?



需要一些架构方面的考虑才能找到最佳位置。
You must introduce a variable with a higher scope. Like a class member (prefered) or a global storage like an list of values. Store as cookie possible?

It need some architectural considerations to find the best place.


这篇关于即使在后端存储数据后仍保留文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆