m0_37710580
Mr.Daru
采纳率76.5%
2017-03-13 15:59 阅读 857
已采纳

saveOrUpdate event with null entity

5

看不出哪里问题,能进入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条回答 默认 最新

相关推荐