java - 如何在 Struts2 中进行子字符串化?

标签 java struts2 substring

如何使用 Struts2 标签库对字符串进行子字符串化?

这是我使用 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)} "/>

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

最佳答案

假设 firstName 是一个 java.lang.String 那么:

<s:property value="firstName.substring(0,5)" />

关于java - 如何在 Struts2 中进行子字符串化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5313206/

相关文章:

java - Struts2 中的 exceptParams 实际上排除了什么?

regex - 从postgres中的文本字符串中提取子字符串

Python:有效替换子字符串

java - 皮尼乌斯。导入错误: DLL load failed: The specified module was not found

java - 线程是否曾经自杀或停止运行

java - Amazon EC2 中的 Apache Tomcat 错误 : could not find org. apache.catalina.util.ServerInfo

在c中创建一个具有start和end的子字符串

java - Apache HttpResponse 获取未格式化的字符串而不是 XML

java - Struts2、Hibernate与企业应用程序集成时出现JasperException

java - 如何强制一个方法只接受 Struts2 中的 POST 参数?