如何在Struts2中子串? [英] How to substring in Struts2?
本文介绍了如何在Struts2中子串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用 Struts2 标签库对字符串进行子串化?
How can I substring a string using Struts2 taglibs?
这是我使用 JSTL/EL 的尝试:
This is my attempt using 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)} "/>
然而这不起作用.我怎样才能达到我的要求?
This does however not work. How can I achieve my requirement?
推荐答案
您可以使用 JSP EL 作为 ${action.property}
引用动作属性.
You can reference action properties using JSP EL as ${action.property}
.
<c:out value="${fn:substring(action.firstName, 0, 5)} "/>
这篇关于如何在Struts2中子串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文