新手第一次配置ssh框架 , modeldriven获取不到值,数据库插入的值全部为空。getmodel方法尝试过,无果,求大神讲解。代码如下

[复制链接]
查看11 | 回复4 | 2021-1-27 07:15:46 | 显示全部楼层 |阅读模式
要封装的实体类(Customer):
packagecom.lin.domain;
publicclassCustomer{
privateLongcust_id;
privateStringcust_name;
privateLongcust_user_id;
privateLongcust_create_id;
privateStringcust_source;
privateStringcust_industry;
privateStringcust_level;
privateStringcust_linkman;
privateStringcust_phone;
privateStringcust_mobile;
publicLonggetCust_id(){
returncust_id;
}

publicvoidsetCust_id(Longcust_id){
this.cust_id=cust_id;
}

publicStringgetCust_name(){
returncust_name;
}

publicvoidsetCust_name(Stringcust_name){
this.cust_name=cust_name;
}

publicLonggetCust_user_id(){
returncust_user_id;
}

publicvoidsetCust_user_id(Longcust_user_id){
this.cust_user_id=cust_user_id;
}

publicLonggetCust_create_id(){
returncust_create_id;
}

publicvoidsetCust_create_id(Longcust_create_id){
this.cust_create_id=cust_create_id;
}

publicStringgetCust_source(){
returncust_source;
}

publicvoidsetCust_source(Stringcust_source){
this.cust_source=cust_source;
}

publicStringgetCust_industry(){
returncust_industry;
}

publicvoidsetCust_industry(Stringcust_industry){
this.cust_industry=cust_industry;
}

publicStringgetCust_level(){
returncust_level;
}

publicvoidsetCust_level(Stringcust_level){
this.cust_level=cust_level;
}

publicStringgetCust_linkman(){
returncust_linkman;
}

publicvoidsetCust_linkman(Stringcust_linkman){
this.cust_linkman=cust_linkman;
}

publicStringgetCust_phone(){
returncust_phone;
}

publicvoidsetCust_phone(Stringcust_phone){
this.cust_phone=cust_phone;
}

publicStringgetCust_mobile(){
returncust_mobile;
}

publicvoidsetCust_mobile(Stringcust_mobile){
this.cust_mobile=cust_mobile;
}
}
CustomerAction文件:
publicclassCustomerActionextendsActionSupportimplements
ModelDriven{
privatestaticfinallongserialVersionUID=-6775389972209231951L;
//存储对象要手动new一个类
privateCustomercustomer=newCustomer();
publicCustomergetModel(){
//TODOAuto-generatedmethodstub
returncustomer;
}
//提供service的成员属性,提供set方法
//如果action交给spring管理会失效
privateCustomerServicecustomerService;
publicvoidsetCustomerService(CustomerServicecustomerService){
this.customerService=customerService;
}

publicStringadd(){
System.out.println("保存客户的方法");
System.out.println(customer);
customerService.save(customer);
returnNONE;
}

}

映射文件(Customer.hbm.xml)









applicationContext配置










org.hibernate.dialect.MySQLDialect
true
true
update



com/lin/domain/Customer.hbm.xml


















structs配置:

-->




分 -->
回复

使用道具 举报

千问 | 2021-1-27 07:15:46 | 显示全部楼层
你的action交给spring管理,那你的struts配置文件中还需引入啊
回复

使用道具 举报

千问 | 2021-1-27 07:15:46 | 显示全部楼层
而且你的action好像也没有配置好吧,class属性呢?
回复

使用道具 举报

千问 | 2021-1-27 07:15:46 | 显示全部楼层

这个不是引入吗有点迷
回复

使用道具 举报

千问 | 2021-1-27 07:15:46 | 显示全部楼层








action的class属性有啊,我有问过也是说actionn中set没写这个set要写在哪里呢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行