Determines whether a value contains several ways of writing a specified string.
1.jstl label notation,
The main use is FN, when used, need to introduce
- <%@ taglib prefix="FN" uri="http://java.sun.com/jsp/jstl/functions"%>
- <c:choose>
- <c:when test="${fn:contains (item.name, ' Almighty ')}">
- <strong>
- <font color="Red"><s:property value="item.name" /> </ font>
- </Strong>
- </c:when>
- <c:otherwise>
- <s:property value="item.name" />
- </c:otherwise>
- </c:choose>
2.STRUTS2 Label notation:
- <s:if test="item.name.contains (\" almighty ")">
- <strong>
- <font color="Red"><s:property value="Item.name" /> </Font>
- </Strong>
- </s:if>
- <s:else>
- <s:property value="item.name" />
- </s:else>
3.JSP notation:
For the arguments passed over, you can use the following.
- <%
- String teamName1 = new String (Request.getparameter ("Teamname")
- . GetBytes ("Iso8859-1"), "UTF-8");
- if (Teamname1.contains ("male")) {
- %>
- <input type="hidden" id="Sex" name="Athlete.sex" value="male" />
- <%
- } else if (Teamname1.contains ("female")) {
- %>
- <input type="hidden" id="Sex" name="Athlete.sex" value="female" />
- <%
- }
- %>
This article is from "Ghost Conan's Technical Blog" blog, please be sure to keep this source http://enetq.blog.51cto.com/479739/933533
Struts tags, jstl tags and other judgment strings contain