导航:首页 > 净水问答 > htmlselect过滤

htmlselect过滤

发布时间:2022-08-05 16:10:58

㈠ 用正则表达式过滤HTML标签

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* <p>
* Title: HTML相关的正则表达式工具类
* </p>
* <p>
* Description: 包括过滤HTML标记,转换HTML标记,替换特定HTML标记
* </p>
* <p>
* Copyright: Copyright (c) 2006
* </p>
*
* @ hejian
* @version 1.0
* @createtime 2006-10-16
*/

public class HtmlRegexpUtil {
private final static String regxpForHtml = "<([^>]*)>"; // 过滤所有以<开头以>结尾的标签

private final static String regxpForImgTag = "<\\s*img\\s+([^>]*)\\s*>"; // 找出IMG标签

private final static String regxpForImaTagSrcAttrib = "src=\"([^\"]+)\""; // 找出IMG标签的SRC属性

/**
*
*/
public HtmlRegexpUtil() {
// TODO Auto-generated constructor stub
}

/**
*
* 基本功能:替换标记以正常显示
* <p>
*
* @param input
* @return String
*/
public String replaceTag(String input) {
if (!hasSpecialChars(input)) {
return input;
}
StringBuffer filtered = new StringBuffer(input.length());
char c;
for (int i = 0; i <= input.length() - 1; i++) {
c = input.charAt(i);
switch (c) {
case '<':
filtered.append("<");
break;
case '>':
filtered.append(">");
break;
case '"':
filtered.append(""");
break;
case '&':
filtered.append("&");
break;
default:
filtered.append(c);
}

}
return (filtered.toString());
}

/**
*
* 基本功能:判断标记是否存在
* <p>
*
* @param input
* @return boolean
*/
public boolean hasSpecialChars(String input) {
boolean flag = false;
if ((input != null) && (input.length() > 0)) {
char c;
for (int i = 0; i <= input.length() - 1; i++) {
c = input.charAt(i);
switch (c) {
case '>':
flag = true;
break;
case '<':
flag = true;
break;
case '"':
flag = true;
break;
case '&':
flag = true;
break;
}
}
}
return flag;
}

/**
*
* 基本功能:过滤所有以"<"开头以">"结尾的标签
* <p>
*
* @param str
* @return String
*/
public static String filterHtml(String str) {
Pattern pattern = Pattern.compile(regxpForHtml);
Matcher matcher = pattern.matcher(str);
StringBuffer sb = new StringBuffer();
boolean result1 = matcher.find();
while (result1) {
matcher.appendReplacement(sb, "");
result1 = matcher.find();
}
matcher.appendTail(sb);
return sb.toString();
}

/**
*
* 基本功能:过滤指定标签
* <p>
*
* @param str
* @param tag
* 指定标签
* @return String
*/
public static String fiterHtmlTag(String str, String tag) {
String regxp = "<\\s*" + tag + "\\s+([^>]*)\\s*>";
Pattern pattern = Pattern.compile(regxp);
Matcher matcher = pattern.matcher(str);
StringBuffer sb = new StringBuffer();
boolean result1 = matcher.find();
while (result1) {
matcher.appendReplacement(sb, "");
result1 = matcher.find();
}
matcher.appendTail(sb);
return sb.toString();
}

/**
*
* 基本功能:替换指定的标签
* <p>
*
* @param str
* @param beforeTag
* 要替换的标签
* @param tagAttrib
* 要替换的标签属性值
* @param startTag
* 新标签开始标记
* @param endTag
* 新标签结束标记
* @return String
* @如:替换img标签的src属性值为[img]属性值[/img]
*/
public static String replaceHtmlTag(String str, String beforeTag,
String tagAttrib, String startTag, String endTag) {
String regxpForTag = "<\\s*" + beforeTag + "\\s+([^>]*)\\s*>";
String regxpForTagAttrib = tagAttrib + "=\"([^\"]+)\"";
Pattern patternForTag = Pattern.compile(regxpForTag);
Pattern patternForAttrib = Pattern.compile(regxpForTagAttrib);
Matcher matcherForTag = patternForTag.matcher(str);
StringBuffer sb = new StringBuffer();
boolean result = matcherForTag.find();
while (result) {
StringBuffer sbreplace = new StringBuffer();
Matcher matcherForAttrib = patternForAttrib.matcher(matcherForTag
.group(1));
if (matcherForAttrib.find()) {
matcherForAttrib.appendReplacement(sbreplace, startTag
+ matcherForAttrib.group(1) + endTag);
}
matcherForTag.appendReplacement(sb, sbreplace.toString());
result = matcherForTag.find();
}
matcherForTag.appendTail(sb);
return sb.toString();
}
}

㈡ html中select是什么意思

select 元素可创建单选或多选菜单

<select>
<option value ="读书">读书</option>
<option value ="逛街">逛街</option>
<option value="玩游戏">玩游戏</option>
<option value="跑步">跑步</option>
</select>

㈢ select语句的过滤条件既可以放在where子句中,也可以放在from子句中

SELECT 列名称 FROM 表名称
where 条件

㈣ html 中禁止 select选择

您好,要使标签禁用,肯定是要添加一个属性来控制,这个属性在检查代码时候肯定会显示在标签里。
你可以自己写个属性,而不用disable。自己定义属性的功能。

㈤ select 里怎么按计算后的结果过滤

select a,b from tb1 where a>b
如果必须使用c
select a,b,a-b as c from tb1 where a>b

在数据结构不改的情况下,要进行 SQL优化,方便的话,把完整的SQL给我看看。如不方便公开可以用消息的方法给我。

㈥ 关于<html:select>的问题,谢谢

Struts中的下拉列表标签的使用
页面中经常用到下拉列表,下面是个人对于STRUTS中标签使用的一点总结:
STRUTS中的下拉选择列表标签必须嵌套在<html:form>标签中,包括:
1.<html:select>
2.<html:option>
3.<html:options>
4.<html:optionsCollection>

使用时嵌套如下:
<html:select property="ationForm.property">
<html:option>或<html:options>或<html:optionsCollection>
</html:select>
其中property为ActionForm中对应的一个属性.

1.<html:option>
<html:option value="value">displayName</html:option>
其中value为实际使用的值(赋值到ActionForm对应的属性中) displayName页面中显示的信息.
例:<html:option value=""></html:option>显示一个空白选择,值为"".

2..<html:options>
<html:options collection="collection" labelProperty="displayName" property="value"/>
其中collection为一个集合,一般是个ArrayList,displayName为前台显示的名称,value为后台实际使用的值.
例:<html:options collection="arrayList" labelProperty="name" property="id" />

3..<html:optionsCollection>
<html:optionsCollection property="actionForm.property" label="displayName" value="value"/>
其中property为ActionForm中的一个属性,为一个集合.displayName为前台显示的名称,value为后台实际使用的值.
例:<html:optionsCollection property="listProperty" label="name" value="id" />

补充一点:如果要从 数据库去取数据,一般是在 action 里调用 DAO ,把结果存入一个ArrayList作为 request 的一个属性传到页面上; 这时一般用 <html:options .../> 标签.另外,如果数据不从数据库去取,而是代码固定的,则一般把这种放到 ActionForm 里,作为属性在页面上取,这时一般用 <html:optionsCollection ... />

㈦ 关于html中的select标签的问题

if(this.selected)这句话的意思是,如果下拉框有选中项,就....然而不管你选择可以编辑还是选择不可编辑,都满足下拉框有选中项这个条件的,所以只要你下拉框的项一选,永远都是不可编辑,也就是永远都执行txtNo.disabled=false这句。修改方法是将条件改成如果选中的值是0那么,让文本框可以编辑,否则不可编辑。 修改方法:if(this.selected)改为if(this.value == '0')

㈧ 关于HTML的select 元素

呵呵~这样搞:

<select name="listZhiwei" size="1">
<option selected>请选择</option>
<option value="xtwh"> 系统维护员</option>
<option value="cw">财务</option>
<option value="zhb">综合部</option>
<option value="swb">商务部</option>
<option value="scb">市场部</option>
<option value="wlb">物流部</option>
<option value="shb">售后部
<option value="kf">库房</option>
</select>

我给你默认的是“请选择”三个字,如果你一定要显示空白,请把这三个字替换成一空格就ok了。

阅读全文

与htmlselect过滤相关的资料

热点内容
怡口净水器现在的价格是多少 浏览:617
危废里废弃的离子交换树脂 浏览:662
厦门超纯水设备什么牌子好 浏览:706
废液废水泄漏应急预案 浏览:774
净化器自来水口怎么接 浏览:298
重庆废水处理公司 浏览:768
为什么核废水不能稀释 浏览:547
超滤和纯水制出来的冰 浏览:711
烧烤车净化器怎么调节 浏览:1000
云南多效蒸馏水机 浏览:713
化学实验过滤实验报告 浏览:215
广告过滤无法清楚 浏览:63
优瑞x9咖啡机除垢 浏览:888
制糖企业如何治理废水 浏览:605
直饮水机脏了会怎么样 浏览:987
净水器废水还能洗菜吗 浏览:1000
企石工厂污水排放 浏览:77
反渗透膜上的活性炭怎么回事 浏览:895
滤芯漏机油怎么能看出来 浏览:602
瓷器上的水垢如何清除 浏览:192