軟件下載
文件大小:
軟件介紹
view plaincopy to clipboardPRint?
1,頁面上編碼設置為"UTF-8"
2,寫一個字符編碼過濾器, 在web.xml中配置加載過濾器
3,設置tomcat的屬性 在配置端口的節(jié)點上加入如下代碼:URIEncoding="UTF-8"
1,代碼如下:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
2,實現(xiàn)代碼:
package com.mww.comm;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class checkEcodingFelter implements Filter {
public void destroy() {
// TODO Auto-generated method stub
}
public void doFilter(ServletRequest servletrequest,
ServletResponse servletresponse, FilterChain filterChain)
throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletrequest;
HttpServletResponse response = (HttpServletResponse) servletresponse;
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
filterChain.doFilter(servletrequest, servletresponse);
}
public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub
}
}
在web.xml中配置過濾器:
<!-- 字符編碼過濾 -->
<filter>
<filter-name>checkEcodingFelter </filter-name>
<filter-class>com.mww.comm.checkEcodingFelter </filter-class> <!-- 配置過濾器類 包名+類名 -->
</filter>
<filter-mapping>
<filter-name>checkEcodingFelter </filter-name>
<url-pattern>/* </url-pattern> <!-- 過濾所有頁面-->
</filter-mapping>
3,在tomcat配置端口的節(jié)點上配置該屬性URIEncoding="UTF-8" :
<Connector port="8888" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8"/>
按這一套下來亂碼問題解
1,頁面上編碼設置為"UTF-8"
2,寫一個字符編碼過濾器, 在web.xml中配置加載過濾器
3,設置tomcat的屬性 在配置端口的節(jié)點上加入如下代碼:URIEncoding="UTF-8"
1,代碼如下:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
2,實現(xiàn)代碼:
package com.mww.comm;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class checkEcodingFelter implements Filter {
public void destroy() {
// TODO Auto-generated method stub
}
public void doFilter(ServletRequest servletrequest,
ServletResponse servletresponse, FilterChain filterChain)
throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletrequest;
HttpServletResponse response = (HttpServletResponse) servletresponse;
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
filterChain.doFilter(servletrequest, servletresponse);
}
public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub
}
}
在web.xml中配置過濾器:
<!-- 字符編碼過濾 -->
<filter>
<filter-name>checkEcodingFelter </filter-name>
<filter-class>com.mww.comm.checkEcodingFelter </filter-class> <!-- 配置過濾器類 包名+類名 -->
</filter>
<filter-mapping>
<filter-name>checkEcodingFelter </filter-name>
<url-pattern>/* </url-pattern> <!-- 過濾所有頁面-->
</filter-mapping>
3,在tomcat配置端口的節(jié)點上配置該屬性URIEncoding="UTF-8" :
<Connector port="8888" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8"/>
按這一套下來亂碼問題解
版權聲明:
1 本站所有資源(含游戲)均是軟件作者、開發(fā)商投稿,任何涉及商業(yè)盈利目的均不得使用,否則產(chǎn)生的一切后果將由您自己承擔!
2 本站將不對任何資源負法律責任,所有資源請在下載后24小時內(nèi)刪除。
3 若有關在線投稿、無法下載等問題,請與本站客服人員聯(lián)系。
4 如侵犯了您的版權、商標等,請立刻聯(lián)系我們并具體說明情況后,本站將盡快處理刪除,聯(lián)系QQ:2499894784
熱門軟件
- 千億體育手機版本v2.0.1 安卓版
- tplink物聯(lián)電腦版(原tplink安防) v2.12.17.
- Sandboxie Plus v1.9.8 / v5.64.8 開源電腦
- 字魂100號方方先鋒體字體包免費版
- 奧維互動地圖奧維地圖PC破解版VIP V9.0.6
- 蘭博對戰(zhàn)平臺 V1.38.6 官方最新版 / 蘭博玩
- reWASD(Xbox One手柄映射工具) V6.0.1.5190
- mtool修改器 V2023.11 官方最新版 / mtool
- 115轉存助手ui優(yōu)化版腳本 V3.9.1 綠色免費
- iSecure Center電腦客戶端 V1.5.0 官方版
最近更新
點擊加載更多評論>>