您的位置:首页 > Web前端 > JavaScript

jsp页面截取字符串

2016-11-24 17:57 274 查看
jsp页面引入:

<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

页面使用:

${fn:substring(<string>, <beginIndex>, <endIndex>)}

页面实例:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>

<body>

jstl的function使用:${fn:substring("abcdefg",0,4)}
</body>
</html>


页面运行结果:

jstl的function使用:abcd

jstl标签库截取字符串参考标准:

http://www.runoob.com/jsp/jstl-function-substring.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: