【问题标题】:Struts2 CRUD, how to update the model : ModelDriven. It's always blank in the JSPStruts2 CRUD,如何更新模型:ModelDriven。在 JSP 中总是空白
【发布时间】:2011-07-14 17:28:01
【问题描述】:

我无法在我的 JSP 中检索我的模型来更新对象。

公共类 ViewDashboardAction 扩展 ActionSupport 实现 ModelDriven { 私人倩碧倩碧=空; @覆盖 公共倩碧getModel(){ 返回倩碧; } 公共字符串执行()抛出异常{ 倩碧 = service.read(1); // 此时我的对象已填充 返回成功; }

在我的 JSP 中,我想要一些简单的东西

但我的文本字段总是空白。

我错过了什么?

【问题讨论】:

    标签: jsp struts2 crud model-driven


    【解决方案1】:

    试试这个

    private Clinique clinique = new Clinique();
    
    @Override
        public Object getModel() {
            return clinique;
        }
    
    
    public void setClinique(Clinique clinique ){
       this.clinique =clinique ;
    }
    
    public Clinique getClinique(){
       return clinique ;
    }
    

    【讨论】:

    • 正是我的想法。 ModelDriven 将用于验证,但不适用于前端。
    • 模型驱动拦截器会在请求处理周期进行时将您的 domian 对象放在值堆栈的顶部,
    猜你喜欢
    • 2011-05-29
    • 1970-01-01
    • 2018-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多