获取变量的值 [英] Get the value of variable

查看:55
本文介绍了获取变量的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为在线考试系统设计项目. 项目正在成功运行.问题在于最终用户会获得应输入数据库的任何标记.

I am making project for an online examination system. Project is running successfully. The problem is that at the end user gets whatever marks that should be entered into database.

我做不到.

我的代码如下.

String UserName = request.getParameter("UserName");
String q = "insert into Data (UserName,MARKS) values("+UserName+" , "+count+")";
System.out.println(q);

在这里,count是存储标记的变量.

Here, count is the variable in that the marks are stored.

我已打印查询.由此可以说,我正在获取count变量的值,但无法获取用户输入的USERNAME的值.

I have printed query. From that I can say that I am getting the value of count variable but I cannot get the value of USERNAME entered by user.

推荐答案

检查参数'UserName'是否正确.

check parameter 'UserName' is correct or not.

UserName可以存储为会话值,之后可以进行检索.

UserName can be stored as session value after that you can retrieve.

 String userName = request.getParameter("txtUserName");

session.setAttribute("userName", userName);
String manager = session.getAttribute("userName");

这篇关于获取变量的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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