简体   繁体   English

Spring MVC中是否有与Struts2的ValueStack类似的东西?

[英]Is there anything similar to Struts2's ValueStack in Spring MVC?

I am new to Spring MVC. 我是Spring MVC的新手。

In my project I print the java object values in JSP using JSTL. 在我的项目中,我使用JSTL在JSP中打印Java对象值。

I assign the values in map object like below. 我在地图对象中分配值,如下所示。

Map<String, Object> result =HashMap<String,Object>();

In Struts2 I get the java object value from ValueStack and print them in JSP using Struts2 tag. 在Struts2中,我从ValueStack获取了Java对象的值,并使用Struts2标记在JSP中打印它们。

My Questions are: 我的问题是:

  1. Is there any ValueStack available in Spring MVC like it is in Struts2 ? 像Struts2一样,Spring MVC中是否有任何ValueStack可用?
  2. If yes, which is its maximum capacity ? 如果是,最大容量是多少?
  3. Which is the right language for displaying values to JSPin Spring MVC ? 在Spring MVC中向JSP显示值的正确语言是哪一种?

I'm definitely not an expert of Spring MVC, but AFAIK there is nothing similar to a Value Stack; 我绝对不是Spring MVC的专家,但是AFAIK没有类似于Value Stack的东西。

Spring MVC is a standard Push-MVC framework: it pushes the values somewhere (session, request, model / modelMap, flashAttributes, etc...) and you retrieve them later by accessing the desired scope / object. Spring MVC是一个标准的Push-MVC框架:它将值推送到某个位置(会话,请求,模型/ modelMap,flashAttributes等),然后稍后通过访问所需的作用域/对象来检索它们。

Struts2 instead is a Pull-MVC framework: it doesn't push anything in the request, in the session ecc... it instead stores everything in the Value Stack, making possible to pull out those values directly from the JSP. 相反,Struts2是Pull-MVC框架:它不会在请求中,会话ecc中推送任何内容……而是将所有内容存储在值堆栈中,从而有可能直接从JSP中提取这些值。 This was actually a great innovation and AFAIK there are not other frameworks like this among the most known ones. 这实际上是一项伟大的创新,并且AFAIK在最知名的框架中没有其他类似的框架。 If you are not using Struts2 (no matter if Spring MVC or others), you generally need to push your stuff somewhere. 如果您不使用Struts2(无论是Spring MVC还是其他),通常都需要将东西推到某个地方。

Since you don't have OGNL available in Spring MVC, you should also use JSTL with JSP EL , and Spring MVC Tags where availables (look for Spring's Form Tag Library in that page) 由于Spring MVC中没有可用的OGNL,因此还应该将JSTLJSP EL ,并在可用的地方使用Spring MVC Tags (在该页面中查找Spring的表单标签库 )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM