struts s:if 截取字符串,判断字符串长度
程序员文章站
2022-06-22 17:08:51
...
[转载]struts s:if 截取字符串,判断字符串长度
(转载地址:请点击上面的链接)
- <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
- <%@ taglib prefix="s" uri="/struts-tags" %>
- <%
- String path = request.getContextPath();
- String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
- %>
- <html>
- <head>
- <title>test</title>
- </head>
- <body>
- <s:if test="user.name.length()>2">
- <s:property value="user.name.substring(0,2)"/>
- </s:if>
- <s:else>
- sun
- </s:else>
- <hr/>
- <s:property value="user.name.length()"/>
- <hr/>
- <s:set name="test" value="user.name" />
- <s:property value="%{test}"/>
- <s:set name="other" value="123" />
- <hr/>
- <s:if test="#test=='sunteststruts' || #test=='123' || #other=='12'">
- afafasf
- </s:if>
- <hr/>
- <s:iterator value="persons" >
- <s:property value="name"/>
- </s:iterator>
- </body>
- </html>