锘??xml version="1.0" encoding="utf-8" standalone="yes"?>а√中文在线天堂精品,国精品**一区二区三区在线蜜桃,精品一区二区三区中文字幕在线http://www.aygfsteel.com/junglesong/category/30227.html涓栦笂鏈棤闅句簨錛屽績浠ヤ負闅撅紝鏂箖鐪熼毦銆傝嫙涓嶅瓨涓闅句箣瑙佷簬蹇冿紝鍒欒繍鐢ㄤ箣鏈嚜鍑恒?/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"));
}
}

浠ヤ笂銆?

]]>
主站蜘蛛池模板:
伊川县|
仁怀市|
炉霍县|
华亭县|
淮南市|
安陆市|
易门县|
肥城市|
林周县|
四子王旗|
桦南县|
天水市|
永修县|
清涧县|
民勤县|
延庆县|
健康|
大兴区|
读书|
平江县|
焦作市|
临汾市|
永宁县|
丹江口市|
张家口市|
达日县|
西丰县|
甘泉县|
怀仁县|
梓潼县|
和田市|
林甸县|
从江县|
洪泽县|
茶陵县|
恩平市|
龙门县|
武胜县|
阳春市|
韶山市|
西华县|