Spring模型对象
我想设置不同的数据,比如
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
a) 你不是在谈论 Spring,你是在谈论 Spring MVC,即基于 Spring 框架构建的 MVC 框架。有区别。
b)您需要为模型属性命名,例如
从 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.
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
为所有简单对象创建一个 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