锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国内精品卡一卡二卡三新区
,亚洲午夜久久久久久尤物,国产精品久久久久久超碰http://www.aygfsteel.com/junglesong/category/30227.html涓栦笂鏈棤闅句簨錛屽績浠ヤ負(fù)闅撅紝鏂箖鐪熼毦銆傝嫙涓嶅瓨涓闅句箣瑙佷簬蹇冿紝鍒欒繍鐢ㄤ箣鏈嚜鍑恒?/description>zh-cnThu, 20 Mar 2008 05:53:18 GMTThu, 20 Mar 2008 05:53:18 GMT60- 濡備綍閰嶇疆filter瑙e喅Struts鐨勪腑鏂囬棶棰?/title>http://www.aygfsteel.com/junglesong/archive/2008/03/20/187459.html鍜岄緇嗛洦鍜岄緇嗛洦Thu, 20 Mar 2008 04:46:00 GMThttp://www.aygfsteel.com/junglesong/archive/2008/03/20/187459.htmlhttp://www.aygfsteel.com/junglesong/comments/187459.htmlhttp://www.aygfsteel.com/junglesong/archive/2008/03/20/187459.html#Feedback0http://www.aygfsteel.com/junglesong/comments/commentRss/187459.htmlhttp://www.aygfsteel.com/junglesong/services/trackbacks/187459.html
package com.sitinspring.filter;

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;


public class SetCharacterEncodingFilter implements Filter
{
protected String encoding = null;

protected FilterConfig filterConfig = null;

protected boolean ignore = true;


public void destroy()
{
this.encoding = null;
this.filterConfig = null;
}

public void doFilter(ServletRequest request, ServletResponse response,

FilterChain chain) throws IOException, ServletException
{

// Conditionally select and set the character encoding to be used

if (ignore || (request.getCharacterEncoding() == null))
{
String encoding = selectEncoding(request);
if (encoding != null)
request.setCharacterEncoding(encoding);
}

// Pass control on to the next filter
chain.doFilter(request, response);

}


public void init(FilterConfig filterConfig) throws ServletException
{

this.filterConfig = filterConfig;
this.encoding = filterConfig.getInitParameter("encoding");
String value = filterConfig.getInitParameter("ignore");
if (value == null)
this.ignore = true;
else if (value.equalsIgnoreCase("true"))
this.ignore = true;
else if (value.equalsIgnoreCase("yes"))
this.ignore = true;
else
this.ignore = false;

}


protected String selectEncoding(ServletRequest request)
{
return (this.encoding);
}

}

2.鍦╓eb.xml涓厤緗繖涓猣ilter銆?br />
<!-- filter -->
<filter>
<filter-name>Set Character Encoding</filter-name>
<filter-class>com.sitinspring.filter.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
3.Action璋冪敤紺轟緥錛?br />
package com.sitinspring.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.PropertyUtils;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;


/** *//**
* Action瀹氫箟澶?br />
* @author sitinspring
*
* @date 2008-3-20
*/

public final class HelloAction extends Action
{
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)

throws Exception
{
request.setCharacterEncoding("UTF-8");

// 鍙朏orm涓弬鏁皀ame
String name = (String) PropertyUtils.getSimpleProperty(form, "name");
request.setAttribute("msg", "嬈㈣繋浣狅紒"+name);

return (mapping.findForward("SayHello"));
}
}

浠ヤ笂銆?

]]>
主站蜘蛛池模板:
保山市|
巴彦淖尔市|
栖霞市|
三河市|
花莲县|
银川市|
饶平县|
张掖市|
洛宁县|
佛坪县|
灵寿县|
游戏|
台州市|
新安县|
郓城县|
石门县|
涟源市|
烟台市|
四平市|
平陆县|
印江|
正安县|
汝南县|
张家港市|
栾城县|
海兴县|
永昌县|
尼玛县|
鹿邑县|
尉犁县|
青海省|
桐城市|
炉霍县|
海淀区|
福建省|
文登市|
醴陵市|
永州市|
潮安县|
德庆县|
绵竹市|