日期:2014-05-17  浏览次数:20856 次

javabean的问题,菜鸟求指导。。。。。急求~~~~
写了一个bean生成的sh.class放在MyEclipse下面的src目录下,然后我在在一个jsp页面里<%@page import="sh"%>老是有错误,can not be resolved代码如下:
HTML code
<%@page language="java" import="java.util.*" pageEncoding="gb2312"%>

<%@page import="sh" %>
<html>
<body>
<%String str=response.encodeURL("Regist.jsp"); 

%>  
    输入你的信息,*号的必须填写:
   <form action="<%=str %>"method="post">
      <br>登陆名称<input type="text" name="logname">*<br>
      <br>密码<input type="text" name="password">*<br>
      <br>电话<input type="text" name="phone"><br>
      <br>地址<input type="text" name="addr">  <br>
      <br><input type="submit" name="g" value="提交">
   </form>
   <jsp:useBean id="login" class="sh" scope="request">
   </jsp:useBean>
   <%String 
    logname="",
    password="",
    phone="",
    addr="";
     
    if(!session.isNew())
    {
     logname=request.getParameter("logname");
     if(logname==null)
     {
      logname="";
      
     }
 
     password=request.getParameter("password");
     if(password==null)
     {
       password="";
     }

     
     phone=request.getParameter("phone");
     if(phone==null)
     {
       phone="";
     }
     
     addr=request.getParameter("addr");
     if(addr==null)
     {
      addr="";
     }
     
    }
    %>
    
    <%
   if(!(session.isNew()))
   {
    
     %>
     <jsp:getProperty property="backNews" name="memberlogin"/>
     <%} %>
   </body>
</html>/code]
bean的代码:[code=Java]import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
public class sh {
String logname="";
String password="";
String phone="";
String addr="";
String backNews;

Connection con;
Statement sql;
 ResultSet rs;
 public sh()
 {
    try
    {
        Class.forName("com.mysql.jdbc.Driver");
        
    } catch(ClassNotFoundException e)
    {
        
    }
 }
 public void setLogname(String name)
 {
     logname=name;
 }
 public String getLongname()
 {
     return logname;
 }
 
 public void setPassword(String p)
 {
     password=p;
 }
 public String getPassword()
 {
     return password;
 }
 
 
 public void setPhone(String ph)
 {
     phone=ph;
 }
 public String getPhone()
 {
     return phone;
 }
 
 
 public void setAddr(String ad)
 {
     addr=ad;
 }
 public String getAddr()
 {
     return addr;
 }


 
}

 



------解决方案--------------------
在前面加个包.