开发者

[PlayFramework]Blob with @Required saves File twice

Model like :

    @Entity
    public class Doc extends Model {
        public Blob tpl;
    }

Controller like:

    public class DocController extends Controller {
        public static void saveDoc(@Required Blob tpl){
           render();  // event no persistence oper开发者_运维百科ation
        }
    }

It will have 2 uploaded file in the data/attachments. even there are no persistence operation in the controller action.


You can pass the Doc object directly into your action (use doc.tpl from the view, rather than just tpl), and then perform the validation on the Object, rather than the Blob itself.

@Entity
public class Doc extends Model {
    @Required
    public Blob tpl;
}

public class DocController extends Controller {
    public static void saveDoc(@Valid Doc doc){
       render();  // event no persistence operation
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜