使用JSTL将此字符串反向输出。

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>string</title>
</head>
<body>
<form>
	一个输入框:<input type="text" name="v">
	<input type="submit" value="ok">
	<c:set var="s" value="${param.v}"></c:set>
</form>
Before:<c:out value="${s}"></c:out><br>
<c:if test="${not empty s}">
	<c:forEach var="i" begin="0" end="${fn:length(s)-1}">
		<c:set var="ns" value="${fn:substring(s,i,i+1)}${ns}"></c:set>
	</c:forEach>
</c:if>
After:${ns}
</body>
</html>

    原文作者:隔壁郑同学
    原文地址: https://blog.csdn.net/weixin_44517301/article/details/103608397
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞