首页 > 解决方案 > Spring MVC 中 s:property 的等价物

问题描述

我目前正在将 Struts2 项目转换为 Spring MVC,并且我正在努力寻找与 Spring 中的 s:property 标记等效的内容。这是我要转换的一些示例:

<s:property value="#contentha.idcontent"/>
<s:property value="%{topRex.idcontent}"/>

谢谢你的帮助 !

标签: springspring-mvcjspstruts2

解决方案


你可以写

${contentha.idcontent}
${topRew.idcontent}

如果你想使用一个标签,你可以写:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<c:out value="${contentha.idcontent}" />
<c:out value="${topRew.idcontent}" default="Value if null" />

这将需要jstl依赖。例如,如果您使用 Maven:

<dependency>
    <groupId>jstl</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
</dependency>

推荐阅读