时常碰见这样的 问题:获取数据库中的文本域的时候经常是在p标签中的,在页面显示的时候也是带着p标签,如何去除p标签呢

这里提供一个使用jstl的方式

1.首先导入jstl的函数标签库

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

2.

下面是JSTL中自带的方法列表以及其描述

函数名 函数说明 使用举例 
fn:contains 判断字符串是否包含另外一个字符串 <c:if test="${fn:contains(name, searchString)}"> 
fn:containsIgnoreCase 判断字符串是否包含另外一个字符串(大小写无关) <c:if test="${fn:containsIgnoreCase(name, searchString)}"> 
fn:endsWith 判断字符串是否以另外字符串结束 <c:if test="${fn:endsWith(filename, ".txt")}"> 
fn:escapeXml 把一些字符转成XML表示,例如<字符应该转为&lt; ${fn:escapeXml(param:info)} 
fn:indexOf 子字符串在母字符串中出现的位置 ${fn:indexOf(name, "-")} 
fn:join 将数组中的数据联合成一个新字符串,并使用指定字符格开 ${fn:join(array, ";")} 
fn:length 获取字符串的长度,或者数组的大小 ${fn:length(shoppingCart.products)} 
fn:replace 替换字符串中指定的字符 ${fn:replace(text, "-", "•")} 
fn:split 把字符串按照指定字符切分 ${fn:split(customerNames, ";")} 
fn:startsWith 判断字符串是否以某个子串开始 <c:if test="${fn:startsWith(product.id, "100-")}"> 
fn:substring 获取子串 ${fn:substring(zip, 6, -1)} 
fn:substringAfter 获取从某个字符所在位置开始的子串
 ${fn:substringAfter(zip, "-")} 
fn:substringBefore 获取从开始到某个字符所在位置的子串 ${fn:substringBefore(zip, "-")} 
fn:toLowerCase 转为小写 ${fn.toLowerCase(product.name)} 
fn:toUpperCase 转为大写字符 ${fn.UpperCase(product.name)} 
fn:trim 去除字符串前后的空格 ${fn.trim(name)}

函数
 描述
 
fn:contains(string, substring)
 如果参数string中包含参数substring,返回true
 
fn:containsIgnoreCase(string, substring)
 如果参数string中包含参数substring(忽略大小写),返回true
 
fn:endsWith(string, suffix)
 如果参数 string 以参数suffix结尾,返回true
 
fn:escapeXml(string)
 将有特殊意义的XML (和HTML)转换为对应的XML character entity code,并返回
 
fn:indexOf(string, substring)
 返回参数substring在参数string中第一次出现的位置
 
fn:join(array, separator)
 将一个给定的数组array用给定的间隔符separator串在一起,组成一个新的字符串并返回。
 
fn:length(item)
 返回参数item中包含元素的数量。参数Item类型是数组、collection或者String。如果是String类型,返回值是String中的字符数。
 
fn:replace(string, before, after)
 返回一个String对象。用参数after字符串替换参数string中所有出现参数before字符串的地方,并返回替换后的结果
 
fn:split(string, separator)
 返回一个数组,以参数separator 为分割符分割参数string,分割后的每一部分就是数组的一个元素
 
fn:startsWith(string, prefix)
 如果参数string以参数prefix开头,返回true
 
fn:substring(string, begin, end)
 返回参数string部分字符串, 从参数begin开始到参数end位置,包括end位置的字符
 
fn:substringAfter(string, substring)
 返回参数substring在参数string中后面的那一部分字符串
 
fn:substringBefore(string, substring)
 返回参数substring在参数string中前面的那一部分字符串
 
fn:toLowerCase(string)
 将参数string所有的字符变为小写,并将其返回
 
fn:toUpperCase(string)
 将参数string所有的字符变为大写,并将其返回
 
fn:trim(string)
 去除参数string 首尾的空格,并将其返回

使用jstl 截取字符串的更多相关文章

  1. 用jstl截取字符串

    用jstl截取字符串 2011-08-01 08:55 5485人阅读 评论(0) 收藏 举报 stringfunctionjavahtmljspencoding jstl以前在jsp页面截取字符串时 ...

  2. JSTL截取字符串

    引入头文件支持<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> &l ...

  3. JSTL截取字符串以及格式化时间

    fn函数里面有很多好用的方法 <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions& ...

  4. 只显示 前100个字 java 实现截取字符串!使用! <c:if test="${fn:length(onebeans.info)>100 }">${ fn:substri

    博客 文章 只显示 前100个字 java 实现截取字符串!使用! <c:if test="${fn:length(onebeans.info)>100 }">$ ...

  5. EL表达式中如何截取字符串

    EL表达式中如何截取字符串 可以截取,用fn函数:<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/ ...

  6. jstl 处理字符串函数 substring spli等

    在jstl中的fn标签也是我们在网页设计中经常要用到的很关键的标签,在使用的时候要先加上头 <%@ taglib uri="http://java.sun.com/jsp/jstl/f ...

  7. ThinkPHP 模板substr的截取字符串函数

    ThinkPHP 模板substr的截取字符串函数在Common/function.php加上以下代码 /** ** 截取中文字符串 **/ function msubstr($str, $start ...

  8. shell编程常用的截取字符串操作

    1.          常用的字符串操作 1.1.           替换字符串:$ echo ${var/ /_}#支持正怎表达式 / /表示搜索到第一个替换,// /表示搜索到的结果全部替换. ...

  9. [No0000A4]DOS命令(cmd)批处理:替换字符串、截取字符串、扩充字符串、获取字符串长度

    1.替换字符串,即将某一字符串中的特定字符或字符串替换为给定的字符串.举例说明其功能:========================================= @echo off set a ...

随机推荐

  1. 为Firefox 添加自定义搜索引擎

    网上流传的 about:config[对于新版已经失效] 以及到Firefox安装目录中修改 的方式不知道为什么我没有成功 现在来个简单点得! 首先我们需要一个可以自定义搜索引擎的插件 Organiz ...

  2. ftp一些东东

    ftp如果绑定域名 登录时登录名应该写成 域名|用户名

  3. HTML的标题样式

    标题样式1 <p> <span style=" text-align: center; padding-bottom: 6px; padding-left: 20px; p ...

  4. 腾讯webqq最新password加密算法,hash算法

    常常在做webqq机器人,可是最头痛的问题就是腾讯常常加一些验证串来防止robot,如今共享出最新的腾讯password加密算法和hash 算法 hash算法 def webqq_hash(i, a) ...

  5. CF-192-diy-2

    题目链接: http://codeforces.com/contest/330 A. Cakeminator 题目意思: 给一个r*c的矩阵方格,有些位置有S,如果某一行和一列都不含标记为S的方格,则 ...

  6. C#中继承,集合(Eleventh day)

    又到了总结知识的时间,今天在云和学院继续学习了继承的一些运用,和集合的运用.下面就总结下来吧 理论: 显示调用父类的构造方法,关键字: base:构造函数不能被继承:子类对象被实例化的时候会先去主动的 ...

  7. PHP - 数组去重,(折中:符串去重)

    [译]更快的方式实现PHP数组去重 Jan 11, 2016 • Hector 原文:Faster Alternative to PHP’s Array Unique Function 概述 使用PH ...

  8. MVC+ADO模式

    MVC+DAO设计模式 博客分类: Java Java WEB开发   MVC+DAO设计模式 本文摘自:http://www.paper.edu.cn    基于MVC+DAO设计模式的Struts ...

  9. CentOS搭建PHP服务器环境(LAMP)

    安装httpd mysql mysql-server php: yum install -y httpd mysql mysql-server php php-devel 安装php的扩展 yum i ...

  10. hdu 2841 Visible Trees

    /** 大意: 求[1,m], [1,n] 之间有多少个数互素...做了 1695 ,,这题就so easy 了 **/ #include <iostream> #include < ...