@Override public void configPlugin(Plugins plugins) { DruidPlugin db=new DruidPlugin("jdbc:mysql://localhost:3306/nosise_data","root","chejdj"); plugins.add(db); ActiveRecordPlugin arp = new ActiveRecordPlugin(db); arp.addMapping("admin","admin_name", Admin.class); arp.addMapping("mobile_sensor","IMEI", MobileSensor.class); arp.addMapping("noise_data","IMEI", NoiseData.class); } public class Admin extends Model<Admin> { public static final Admin dao=new Admin().dao(); } public class LoginController extends Controller{ //web前端的登录信息 //http://localhost:8080/noise_monitor/loginController/request_Login?admin_name=chejdj&admin_password=chejdj public void request_Login(){ System.out.println("调用了requestLogin方法"); String admin_name=getPara("admin_name"); System.out.println("admin_name的值为"+admin_name); String password=getPara("admin_password"); System.out.println("password的值为"+password); //连接数据库失败 if(Admin.dao==null){ System.out.println("Admin.dao为空"); } // new Admin() 操作的时候出现错误 new Admin().set("admin_name","hello").set("admin_password","123").save();
项目:JFinal