Mr.Daru 2017-03-13 15:59 采纳率: 76.5%
浏览 862
已采纳

saveOrUpdate event with null entity

看不出哪里问题,能进入action 但是获取不倒对象

@Action(value="article" ,results={
    @Result (name="success" ,location="/loginFailer.jsp")
})

public class ArticleAction extends ActionSupport{

    private static final long serialVersionUID = -2266695172069461659L;

    @Resource   
    private ArticleService articleServicle;
    private Article article;

    public Article getArticle() {
        return article;
    }

    public void setArticle(Article article) {
        this.article = article;
    }


    public String add(){
        System.out.println("asdasdasd");
        articleServicle.save(article);
        return "success";
    }
}



   <s:form action="article!add">
        <s:textfield name ="article.title" label="title"/>
        <s:textfield name ="article.content" label="content"/>
        <s:textfield name ="article.type" label="type"/>
        <s:textfield name="article.image" label="image"/>
        <s:textfield name="article.keywords" label="keywords"/>
        <s:textfield name="article.editer" label="editer"/>
        <s:submit value="sumbit"/>
   </s:form>  

 @Entity
@Table(name = "article")
public class Article {
@Id
@Column(name = "Id")
@GeneratedValue(strategy = GenerationType.IDENTITY) 
private int id;

@Column(name = "type")
private String type;

@Column(name = "content")
private String content;

@Column(name = "title")
public String title;

@Column(name = "keywords")
private String keywords;

@Column(name = "editer")
private String editer;

@Column(name = "image")
private String image;


public Article(String type,String content,String title,
        String keywords,String editer,String image
        ){
    this.type=type;
    this.content=content;
    this.title=title;
    this.keywords=keywords;
    this.editer=editer;
    this.image=image;

}
/*
略get,set
*/
  • 写回答

1条回答 默认 最新

  • devmiao 2017-03-13 22:55
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度