如何在Struts2中子串?

jal*_*eel 1 java struts2 substring

如何使用Struts2 taglibs对字符串进行子串?

这是我尝试使用JSTL/EL:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
...
<s:property value="firstName" />
<c:set var="string" value="${firstName} "/>
<c:out value="${fn:substring(string,0,5)} "/>
Run Code Online (Sandbox Code Playgroud)

但这不起作用.我怎样才能达到我的要求?

Qua*_*ion 5

假设firstName是java.lang.String,那么:

<s:property value="firstName.substring(0,5)" />
Run Code Online (Sandbox Code Playgroud)