簡體   English   中英

搜索框的輸入文本設計問題

[英]Input Text Design Issue for a search Box

我在做Java Web應用程序,它有一個搜索框。

  <input type="text" id="twotabsearchtextbox" title="Search For"
    value="${requestScope['searchKey']}" name="searchKey"
    autocomplete="off" class="tftextinput" data-nav-tabindex="10"
    tabindex="1"/>

如果我搜索常規的東西,它會很好。 但是如果我尋找

`<div id="test"> </div>`

諸如html內容之類的東西可以很好地搜索,但是我的設計將完全中斷。 為什么會發生? 我搜索蘋果它進入值部分,例如,如果搜索html內容,它就進入值部分。 我如何避免這個問題?

您是否嘗試過StringEscapeUtils.unescapeHtml(you-search-value);

我只是替換了代碼段$ {requestScope ['searchKey']}

<%@ page import="org.apache.commons.lang.StringEscapeUtils" %>
 <%
    String searchkey ="";
    if (request.getParameter("searchKey")!=null) {
        searchkey=request.getParameter("searchKey");
        searchkey=StringEscapeUtils.escapeHtml(searchkey);      
    }
  %>

並根據更改了現有代碼

<input type="text" id="twotabsearchtextbox" title="Search For"
    value="${requestScope['searchKey']}" name="searchKey"
    autocomplete="off" class="tftextinput" data-nav-tabindex="10"
    tabindex="1"/>

現在問題已經解決了

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM