action代码:
public class TestAction extends ActionSupport{
private String name;
@Override
public String execute() throws Exception {
System.out.println(name);
return "success";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
struts.xml代码:
<action name="test" class="com.yna.action.TestAction">
<result>index.jsp</result>
</action>
web.xml代码:
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> 访问时http://localhost:8080/html5/test?name=中 execute方法里面的输出为乱码。(编码格式均为utf-8)
public class TestAction extends ActionSupport{
private String name;
@Override
public String execute() throws Exception {
System.out.println(name);
return "success";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
struts.xml代码:
<action name="test" class="com.yna.action.TestAction">
<result>index.jsp</result>
</action>
web.xml代码:
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> 访问时http://localhost:8080/html5/test?name=中 execute方法里面的输出为乱码。(编码格式均为utf-8)
非常谢谢你的回答。
2。strtus.i18n.encoding设置编码,每次都设置一致