導航:首頁 > 凈水問答 > 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過濾相關的資料

熱點內容
使電鍍廢水成果凍狀加什麼 瀏覽:903
磷化工廢水治理服務方案多少錢 瀏覽:764
水分子可以半透膜 瀏覽:491
富順縣污水廠 瀏覽:539
污水站攪拌機無法運行怎麼辦 瀏覽:530
全國純水機多少錢 瀏覽:514
2014邁銳寶機油濾芯怎麼卸下來 瀏覽:447
青島回北京用隔離嗎 瀏覽:126
污水處理廠做一天休息 瀏覽:456
php正則表達式過濾span 瀏覽:438
空氣濾芯出水是怎麼回事 瀏覽:895
凈水器保險公司怎麼合作 瀏覽:912
凈水器檢修怎麼不停一直出水 瀏覽:87
鞍山車載凈化器大概多少錢 瀏覽:624
活性炭在廢水處理中可以吸附哪些物質 瀏覽:334
反滲透膜多久能氧化 瀏覽:279
安吉爾換完濾芯怎麼搞 瀏覽:167
青島市中水回用環評單位 瀏覽:236
卡薩帝富鍶凈水器怎麼樣 瀏覽:260
滾筒洗衣機過濾袋在哪 瀏覽:352