String sql="insert into UserOpert(UserName,Operation,grade) Values('"Session.getAttribute("UserName")&"','退出系统','"Session.getAttributes("grade")&"')";
提示:
Syntax error on token "Session", delete this token
Session不需要加双引号吗?
------解决方案--------------------------------------------------------
拼装SQL的时候,要注意好其组成的方式,字符串连接用 + 号:
String sql="insert into UserOpert(UserName,Operation,grade) Values('" + Session.getAttribute("UserName") + "','退出系统','" + Session.getAttributes("grade") + "')";
------解决方案--------------------------------------------------------
- Java code
String sql="insert into UserOpert(UserName,Operation,grade) Values('" + Session.getAttribute("UserName") + "','退出系统'," + Session.getAttributes("grade") + ")";