Filter filtering emoji

Source: Internet
Author: User

Interception Device Public classEmojifilter implements Filter {PrivateFilterconfig Filterconfig;  Public voidInit (Filterconfig filterconfig) throws Servletexception {System. out. println ("Filter initialized");  This. Filterconfig =Filterconfig; }     Public voiddestroy () {System. out. println ("Filter destroyed");  This. Filterconfig =NULL; }     Public voidDoFilter (servletrequest request, servletresponse response, Filterchain chain) throws IOException, Servlete xception {chain.dofilter (NewMyrequestwrapper ((httpservletrequest) request), response); }}
Web. XML configuration <!--emoji Filter-    <filter>        <filter-name>emojifilter</filter-name >        <filter-class>com.qtkj.  Base. emojifilter</filter-class>        <init-param>            <param-name>encoding</param-name >            <param-value>utf-8</param-value>        </init-param>    </filter>    <filter-mapping>        <filter-name>EmojiFilter</filter-name>        <url-pattern> /* </url-pattern>    </filter-mapping>
1 Actual Filtration Method2  Public classMyrequestwrapper extends Httpservletrequestwrapper {3      PublicMyrequestwrapper (HttpServletRequest servletrequest) {4 super (ServletRequest);5     }6 7      Publicstring[] getparametervalues (String parameter) {8String[] results =super.getparametervalues (parameter);9         if(Results = =NULL)Ten             return NULL;  One  A         intCount =results.length; -string[] Trimresults =NewString[count]; -          for(inti =0; I < count; i++) {             theTrimresults[i] =Com.qtkj.weixin.utils.EmojiFilter.filterEmoji (Results[i].trim ()); -Trimresults[i]=trimresults[i].replace (" ",""); -         }         -System. out. println ("==========="+trimresults+"----------"); +         returnTrimresults; -     }            + } AThe method of combining emoji treatment method

Filter filtering emoji

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.