struts s:if 擷取字串,判斷字串長度
阿新 • • 發佈:2019-02-11
<%@ 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>