struts2官网中文(JSP页面提交到struts2的Action中后,取得的中文为乱码,网上的方法都没成功,纠结两天了,小弟必重谢、)

本文目录
- JSP页面提交到struts2的Action中后,取得的中文为乱码,网上的方法都没成功,纠结两天了,小弟必重谢、
- struts2中重定向到Action后中文参数变成乱码
- struts2国际化默认加载中文环境而不能切换英文环境
- struts2 文件下载 中文乱码问题
- struts-json-plugin.jar从哪里下载 我的struts2.1.2用的,需要版本一致吗,能不能给个官网下载地址
JSP页面提交到struts2的Action中后,取得的中文为乱码,网上的方法都没成功,纠结两天了,小弟必重谢、
你需要在struts的配置文件中添加
《constant name="struts.i18n.encoding" value="UTF-8" /》
value中的值自己定,然后在action打印下看看取到的值是什么,如果还是乱码就按照网上的方法进行下转码,如果还是乱码的话看看你的tomcat的配置文件需要添加一句话,上边的方法应该就可以解决问题了,不行的话再说
struts2中重定向到Action后中文参数变成乱码
接收的时候用URLDecoder。我刚遇到的问题
我的配置文件,
《action name="*Action" class="articleAction" method="{1}"》
《result name="remove" type="redirectAction"》
《param name="actionName"》loadArticles《/param》
《param name="namespace"》/backstage/home《/param》
《param name="type.type"》${type.type}《/param》
《/result》
《result name="toAddArticle"》/backstage/home/addArticle.jsp《/result》
《/action》
public String execute() throws UnsupportedEncodingException{
String type1 = URLDecoder.decode(this.type.getType(), "utf-8");
this.type.setType(type1);
}
//这个方法绝对值得楼主试一试。注意是在execute里面,我好向在setType里面转换的时候出现了type为空值的现象。祝你成功
struts2国际化默认加载中文环境而不能切换英文环境
package com.ascent.i18n.test;
import java.util.*;
public class ResourceBundleTest {
public static void main(String args) {
//设置本地区语言(默认)
Locale locale = Locale.getDefault();
//可以使用Local的常量设置具体的语言环境
//Locale locale = Locale.US;
//根据地区不同加载不同的资源文件
ResourceBundle rb = ResourceBundle.getBundle("resource", locale);
//根据key获得value值
String title = rb.getString("title");
System.out.println(title);
}
}《span style="color:#ff0000;"》
《/span》
struts2 文件下载 中文乱码问题
在 struts.xml 加 《constant name="struts.i18n.encodeing" value="GBK"/》《!--国际化信息内码--》试试
另外 jsp页面用的什么编码,struts.xml中就用什么编码,例如如果在struts的配置文件中指定的是gbk 那么页面用gb2312和gbk都可以,不要用utf-8,如果struts配置文件中是utf-8,那么页面就用utf-8 不要用gb2312和gbk
struts-json-plugin.jar从哪里下载 我的struts2.1.2用的,需要版本一致吗,能不能给个官网下载地址
***隐藏网址***
页面中点击: struts-2.5.2-lib.zip (19MB)
下载解压后 找找有你想要的jar
maven 中最低版本也就是2.1.8
***隐藏网址***
《dependency》
《groupId》org.apache.struts《/groupId》
《artifactId》struts2-json-plugin《/artifactId》
《version》2.1.8《/version》
《/dependency》

更多文章:
数据库管理系统和数据库系统分别侧重(数据库,数据库管理系统,数据库系统,这三个分别是什么意思并举个实例)
2026年9月7日 17:00
springmvc的依赖(springMVC的注入方式有哪几种,这与springMVC依赖)
2026年9月7日 14:00
display flex 自动换行(overflow-y:hidden;overflow-x:auto;无效解决方法)
2026年9月7日 11:00
timestamp without time zone(Postgresql中to_date()函数使用问题)
2026年9月7日 09:40






