这是一个JAVA代码
package test; 
import org.apache.struts.action.ActionForm; 
public class UserForm extends ActionForm 

  private String name="lpw";//用户名 
  private String ps="1111";//密码 
  public UserForm(){} 
  public void setName(String s) {name=s;} 
  public String getName() {return name;} 
  public void setPs(String s) {ps=s;} 
  public String getPs() {return ps;} 

为何编译时整个代码都报错,
错误内容:非法字符\12288和需要<标示符>请各位大侠帮忙

解决方案 »

  1.   

    private  和 public前面的空格去掉就可以了有非法字符
      

  2.   

    果然,谢谢啊,
    现在还是报错
    说org.apache.struts.action.ActionForm;不存在
    不能继承ActionForm
    怎么解决啊,我的配置有问题,但不知道怎么配置STRUTS路径。
    再帮下忙谢谢
      

  3.   

    你要把Struts.jar 放到classpath里面
      

  4.   

    这段代码使用jc写的吧,用jb就没事了,很保姆的,都可以点出来的。。
      

  5.   

    package Bean;
    public class sample1Bean {
      private String rs=null;
      private String sample =null,password=null;
      /**Access sample property*/
      public String getSample() {
        return rs;
      }
      /**Access sample property*/
      public void setSample(String newValue,String newPassword) {
    sample=newValue;
    userpassword=newPassword;
    rs=new JDBCtest().conSQL(sample,userpassword);
      }
    }另外一个类
    package Bean;
    import java.sql.*;
    import java.awt.*;
    public class JDBCtest{
    public String conSQL(String sample,String userpassword)
    {
      String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=issa";
      Connection con=null;
      String user=sample;
      String password=userpassword; 
      Statement sm=null;
      ResultSet rs=null;
      String all=null;
      try
      {
        Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
      }
      catch(Exception e)
      {
      System.out.println("失败");
      
      }
      try
      {
        con=DriverManager.getConnection(url,user, password);
        sm=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
        rs=sm.executeQuery("select * from shop");
        while(rs.next())
        {
          int num=rs.getInt(1);
          String thingname=rs.getString(2);
          String type=rs.getString(3);
          int cost=rs.getInt(4);
    all=num+thingname+type+cost;    }
       }
        catch(SQLException e)
        {
          e.printStackTrace();
        }
        finally
        {
          try
          {
    if(rs!=null) {
      rs.close();

    if(sm!=null) {
      sm.close();

    if(con!=null) {
      con.close();

          }
          catch(SQLException e)
          {}
          }
      return all;
        }
       }
      

  6.   

    把包加到classpath或者建个内部的lib把包放进去!!
    如果是myEclipse的话就更方便了!在你的项目名上 点右键(myEclipse) 有一个struts的选项