Spring模型对象

发布于 2024-12-09 13:14:46 字数 987 浏览 0 评论 0原文

我想设置不同的数据,比如

    SoyMapData dataFormsMenu=new SoyMapData(
            "class","menu horizontal",
            "caption","",
            "id","dfMenu",
            "innerContainer","div",
            "helper","span",
            "items",new SoyListData( 
            new SoyMapData ("caption", "Manage Dataforms",
                    "class", "",
                    "link", "#"),
                    new SoyMapData("caption", "viewForm",
                    "class", "",
                    "link", "#")
                    ));
      SoyMapData mainMenu = new SoyMapData(
                "class","menu horizontal dropdown",
                "caption","",
                "id","mainMenu",
                "container","div",
                "contClass","navigation main left",
                "items",captionData);

设置到 Spring 的模型对象中,

model.addattribute("",mainmenu);
model.addattribute("",dfmenu);

如何在 Spring 中执行此操作。

I want to set to different data,like

    SoyMapData dataFormsMenu=new SoyMapData(
            "class","menu horizontal",
            "caption","",
            "id","dfMenu",
            "innerContainer","div",
            "helper","span",
            "items",new SoyListData( 
            new SoyMapData ("caption", "Manage Dataforms",
                    "class", "",
                    "link", "#"),
                    new SoyMapData("caption", "viewForm",
                    "class", "",
                    "link", "#")
                    ));
      SoyMapData mainMenu = new SoyMapData(
                "class","menu horizontal dropdown",
                "caption","",
                "id","mainMenu",
                "container","div",
                "contClass","navigation main left",
                "items",captionData);

into model object of spring,

model.addattribute("",mainmenu);
model.addattribute("",dfmenu);

how to do this in spring.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一萌ing 2024-12-16 13:14:46

a) 你不是在谈论 Spring,你是在谈论 Spring MVC,即基于 Spring 框架构建的 MVC 框架。有区别。

b)您需要为模型属性命名,例如

model.addattribute("main",mainmenu);
model.addattribute("df",dfmenu);

从 JSP(或其他视图)访问数据

然后您可以使用${main.id}${main[id ]}

取决于 SoyMapData 的内部运作

a) you are not talking about Spring, you are talking about Spring MVC, the MVC framework built upon the Spring framework. There's a difference.

b) you need to give the model attribute a name, e.g.

model.addattribute("main",mainmenu);
model.addattribute("df",dfmenu);

Then you can access the data from a JSP (or other view) using

${main.id} or ${main[id]},

depending on the inner workings of SoyMapData

梦里°也失望 2024-12-16 13:14:46

为所有简单对象创建一个 bean;然后将它们连接起来以获得复杂的对象。例如,为每个简单的 SoyMapData 对象创建一个 bean(一个用于“管理数据表单”,一个用于“”viewForm”...),然后通过设置属性/通过构造函数使用它们来获取 dataFormsMenu bean 对象

create a bean for all simple objects; then connect them to get your complex object. For example, create a bean for each simple SoyMapData objects (one for "Manage Dataform, one for ""viewForm" ...), then use them to get dataFormsMenu bean object by setting property/via constructor

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文