jsp中cannot be resolved
str3cannotberesolved<%@pagecontentType="text/html;charset=UTF-8"pageEncoding="UTF-8"i...
str3 cannot be resolved
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"import="java.sql.*"import="string" %>
<%request.setCharacterEncoding("UTF-8");%>
<%Connection con=null; Statement s=null; ResultSet rs=null;//声明三类对象%>
<html><body><table border=1 align="center">
<tr><th>职工号</th><th>姓名</th><th>性别</th><th>工资</th><th>职称</th></tr>
<%
String driverName="com.mysql.jdbc.Driver";
String userName="root";
String userPasswd="";
String dbName="shiyan";
String tableName="shuju";
String url="jdbc:mysql://localhost:3306/"+dbName;
Class.forName(driverName).newInstance();//加载jdbc驱动程序
con=DriverManager.getConnection(url,userName,userPasswd);//连接数据库
%>
<% int a=0;
String b1="查看数据";
String b2="添加数据";
String b3="修改数据";
String b4="删除数据";
String Ncounter[]=request.getParameterValues("item");
if(Ncounter!=null)
for(int k=0;k<Ncounter.length;k++)
{
byte c[]=Ncounter[k].getBytes("GBK");
String str3=new String(c);
out.println(str3);
}
if(str3.equals(b1)){a=1;out.println(b1);};
if(request.getParameterValues("item").equals(b2)){a=2;};
if(request.getParameterValues("item").equals(b3)){a=3;};
if(request.getParameterValues("item").equals(b4)){a=4;};
switch(a)
{
case 1:
break;
case 2:
String co=request.getParameter("count");
String rn=request.getParameter("realname");
String ge=request.getParameter("gender");
String go=request.getParameter("gongzi");
String zh=request.getParameter("zhicheng");
s=con.createStatement();
String str="'"+co+"'"+","+"'"+rn+"'"+","+"'"+ge+"'"+","+"'"+go+"'"+","+"'"+zh+"'";
out.println("输入数据如下:<br>");
out.println(str+"<br><br>");
out.print("我们已将数据存入数据库,如下");
String sql1="insert into shuju values("+str+")";//插入语句
//s.execute(sql1);//执行插入
break;
default:
break;
}
s=con.createStatement();
String sql="SELECT*FROM shuju";
rs=s.executeQuery(sql);
while(rs.next())
{
out.println("<tr>");
out.println("<td>"+rs.getString("职工号")+"</td>");
out.println("<td>"+rs.getString("姓名")+"</td>");
out.println("<td>"+rs.getString("性别")+"</td>");
out.println("<td>"+rs.getString("工资")+"</td>");
out.println("<td>"+rs.getString("职称")+"</td>");
out.println("</tr>");
}
rs.close();s.close();con.close();
%>
</table></body></html>
不懂为什么会有这种情况啊,求解 展开
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"import="java.sql.*"import="string" %>
<%request.setCharacterEncoding("UTF-8");%>
<%Connection con=null; Statement s=null; ResultSet rs=null;//声明三类对象%>
<html><body><table border=1 align="center">
<tr><th>职工号</th><th>姓名</th><th>性别</th><th>工资</th><th>职称</th></tr>
<%
String driverName="com.mysql.jdbc.Driver";
String userName="root";
String userPasswd="";
String dbName="shiyan";
String tableName="shuju";
String url="jdbc:mysql://localhost:3306/"+dbName;
Class.forName(driverName).newInstance();//加载jdbc驱动程序
con=DriverManager.getConnection(url,userName,userPasswd);//连接数据库
%>
<% int a=0;
String b1="查看数据";
String b2="添加数据";
String b3="修改数据";
String b4="删除数据";
String Ncounter[]=request.getParameterValues("item");
if(Ncounter!=null)
for(int k=0;k<Ncounter.length;k++)
{
byte c[]=Ncounter[k].getBytes("GBK");
String str3=new String(c);
out.println(str3);
}
if(str3.equals(b1)){a=1;out.println(b1);};
if(request.getParameterValues("item").equals(b2)){a=2;};
if(request.getParameterValues("item").equals(b3)){a=3;};
if(request.getParameterValues("item").equals(b4)){a=4;};
switch(a)
{
case 1:
break;
case 2:
String co=request.getParameter("count");
String rn=request.getParameter("realname");
String ge=request.getParameter("gender");
String go=request.getParameter("gongzi");
String zh=request.getParameter("zhicheng");
s=con.createStatement();
String str="'"+co+"'"+","+"'"+rn+"'"+","+"'"+ge+"'"+","+"'"+go+"'"+","+"'"+zh+"'";
out.println("输入数据如下:<br>");
out.println(str+"<br><br>");
out.print("我们已将数据存入数据库,如下");
String sql1="insert into shuju values("+str+")";//插入语句
//s.execute(sql1);//执行插入
break;
default:
break;
}
s=con.createStatement();
String sql="SELECT*FROM shuju";
rs=s.executeQuery(sql);
while(rs.next())
{
out.println("<tr>");
out.println("<td>"+rs.getString("职工号")+"</td>");
out.println("<td>"+rs.getString("姓名")+"</td>");
out.println("<td>"+rs.getString("性别")+"</td>");
out.println("<td>"+rs.getString("工资")+"</td>");
out.println("<td>"+rs.getString("职称")+"</td>");
out.println("</tr>");
}
rs.close();s.close();con.close();
%>
</table></body></html>
不懂为什么会有这种情况啊,求解 展开
2个回答
展开全部
改成
<form method="POST" action="login.jsp">
<%
//是否登陆
String usr=(String)session.getValue("user_name");
if(usr!=null && !usr.equals(""))
{
String name=(String)session.getAttribute("user_name");
String sql="select * from member where user_name='"+name+"'";
//ResultSet rs=null;
rs=stmt.executeQuery(sql);
if(rs.next()){
%>
打字不易,如满意,望采纳。
<form method="POST" action="login.jsp">
<%
//是否登陆
String usr=(String)session.getValue("user_name");
if(usr!=null && !usr.equals(""))
{
String name=(String)session.getAttribute("user_name");
String sql="select * from member where user_name='"+name+"'";
//ResultSet rs=null;
rs=stmt.executeQuery(sql);
if(rs.next()){
%>
打字不易,如满意,望采纳。
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询