问题描述
为什么我调用方法的时候乱码而且使用main方法调用方法就是控制台调用方法的时候存进去不乱吗使用struts请求action调用方法存进去就乱码了main跟action调用的一个方法里面值也是写死的并没有用struts传值问题就在于web请求https是不是需要配置什么从控制台上就没问题这是问题!!!!要死了在线等!!!!
解决方案
解决方案二:
request、response什么的都可以设置制定的编码格式的,你设置一下,还有你的文件右键属性设置一下编码格式,都统一了
解决方案三:
引用楼主qq526155988的回复:
为什么我调用方法的时候乱码而且使用main方法调用方法就是控制台调用方法的时候存进去不乱吗使用struts请求action调用方法存进去就乱码了main跟action调用的一个方法里面值也是写死的并没有用struts传值问题就在于web请求https是不是需要配置什么从控制台上就没问题这是问题!!!!要死了在线等!!!!
是的我都设置了你说的request在哪里设置?StringaccountNo="6225123456789";StringaccountName="王府井测试1";StringaccountCard="2203811234567894";StringbankAllName="招商银行";StringbankBranchName="招商银行上地支行";StringbankNumber="141";StringrecDepType="01";StringaccountProvince="北京";StringaccountCity="北京";Stringmemo="王府井测试备注";StringbusiTransNO=getUUID();StringrequestTime=DateTools.getDate("yyyy-MM-ddHH:mm:ss.SSS");Stringsign=MD5Utils.getMD5String(transCode+aliasAccount+channel+requestTime);
我直接写死了publicStringhttpsPost(Stringcontent){StringresponseMessage="";BufferedReaderbufferedReader=null;try{register();HttpPosthttpPost=newHttpPost(httpsUrl);httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,60000);httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT,30000);//构造最简单的字符串数据StringEntityreqEntity=newStringEntity(content);//设置类型reqEntity.setContentType("application/x-www-form-urlencoded;charset=UTF-8");//设置请求的数据httpPost.setEntity(reqEntity);HttpResponseresponse=httpClient.execute(httpPost);HttpEntityentity=response.getEntity();if(entity!=null){bufferedReader=newBufferedReader(newInputStreamReader(entity.getContent()));StringBufferstb=newStringBuffer();Stringline=null;while((line=bufferedReader.readLine())!=null){stb.append(line);}responseMessage=stb.toString();}EntityUtils.consume(entity);}catch(Exceptione){e.printStackTrace();}finally{if(bufferedReader!=null){try{bufferedReader.close();}catch(IOExceptione){e.printStackTrace();}}httpClient.getConnectionManager().shutdown();}returnresponseMessage;}
这是httpspost的代码
解决方案四:
什么是存进去就乱码?存进哪里了?存了哪些字段值?“struts请求action”——这个我能理解成就是Http请求吗?
解决方案五:
引用3楼gaofuqi的回复:
什么是存进去就乱码?存进哪里了?存了哪些字段值?“struts请求action”——这个我能理解成就是Http请求吗?
publicstaticvoidcreatecustomer(RequestMessagermsg){System.out.println(rmsg);RequestMessagerequestMessage=newRequestMessage();//CRB创建账户StringtransCode="CRB";Stringchannel="ch";StringuserNO="ch";Stringpassword="123456";StringaccountNo=rmsg.getAccountNo();StringaccountName=rmsg.getAccountName();SimpleDateFormatdateFormat=newSimpleDateFormat("yyyyMMddHHmmssSSS");//可以方便地修改日期格式Datedate=newDate();Stringhehe=dateFormat.format(date);StringaliasAccount="changhw"+hehe;StringbankAllName=rmsg.getBankAllName();StringbankBranchName=rmsg.getBankBranchName();StringrecDepType=rmsg.getRecDepType();StringaccountProvince=rmsg.getAccountProvince();StringaccountCity=rmsg.getAccountCity();StringbusiTransNO=getUUID();StringrequestTime=DateTools.getDate("yyyy-MM-ddHH:mm:ss.SSS");Stringsign=MD5Utils.getMD5String(transCode+aliasAccount+channel+requestTime);requestMessage.setTransCode(transCode);requestMessage.setChannel(channel);requestMessage.setUserNO(userNO);requestMessage.setPassword(password);requestMessage.setAliasAccount(aliasAccount);requestMessage.setAccountNo(accountNo);requestMessage.setAccountName(accountName);requestMessage.setBankAllName(bankAllName);requestMessage.setBankBranchName(bankBranchName);requestMessage.setAccountProvince(accountProvince);requestMessage.setAccountCity(accountCity);requestMessage.setRecDepType(recDepType);requestMessage.setBusiTransNO(busiTransNO);requestMessage.setRequestTime(requestTime);requestMessage.setSign(sign);System.out.println(requestMessage);Stringcontent=JSON.toJSONString(requestMessage);System.out.println("明文内容为:"+content);StringsecurityContent=HttpsAuthTools.encrypt(content);System.out.println("密文内容为:"+securityContent);wfjHttpsSend(securityContent);}
这个方法后台执行通过main调用就可以实现但是通过action调用这个方法就不行了
解决方案六:
引用4楼qq526155988的回复:
Quote: 引用3楼gaofuqi的回复:
什么是存进去就乱码?存进哪里了?存了哪些字段值?“struts请求action”——这个我能理解成就是Http请求吗?publicstaticvoidcreatecustomer(RequestMessagermsg){System.out.println(rmsg);RequestMessagerequestMessage=newRequestMessage();//CRB创建账户StringtransCode="CRB";Stringchannel="ch";StringuserNO="ch";Stringpassword="123456";StringaccountNo=rmsg.getAccountNo();StringaccountName=rmsg.getAccountName();SimpleDateFormatdateFormat=newSimpleDateFormat("yyyyMMddHHmmssSSS");//可以方便地修改日期格式Datedate=newDate();Stringhehe=dateFormat.format(date);StringaliasAccount="changhw"+hehe;StringbankAllName=rmsg.getBankAllName();StringbankBranchName=rmsg.getBankBranchName();StringrecDepType=rmsg.getRecDepType();StringaccountProvince=rmsg.getAccountProvince();StringaccountCity=rmsg.getAccountCity();StringbusiTransNO=getUUID();StringrequestTime=DateTools.getDate("yyyy-MM-ddHH:mm:ss.SSS");Stringsign=MD5Utils.getMD5String(transCode+aliasAccount+channel+requestTime);requestMessage.setTransCode(transCode);requestMessage.setChannel(channel);requestMessage.setUserNO(userNO);requestMessage.setPassword(password);requestMessage.setAliasAccount(aliasAccount);requestMessage.setAccountNo(accountNo);requestMessage.setAccountName(accountName);requestMessage.setBankAllName(bankAllName);requestMessage.setBankBranchName(bankBranchName);requestMessage.setAccountProvince(accountProvince);requestMessage.setAccountCity(accountCity);requestMessage.setRecDepType(recDepType);requestMessage.setBusiTransNO(busiTransNO);requestMessage.setRequestTime(requestTime);requestMessage.setSign(sign);System.out.println(requestMessage);Stringcontent=JSON.toJSONString(requestMessage);System.out.println("明文内容为:"+content);StringsecurityContent=HttpsAuthTools.encrypt(content);System.out.println("密文内容为:"+securityContent);wfjHttpsSend(securityContent);}
这个方法后台执行通过main调用就可以实现但是通过action调用这个方法就不行了
哪一句代码打印乱码了?
解决方案七:
引用5楼gaofuqi的回复:
Quote: 引用4楼qq526155988的回复:
Quote: 引用3楼gaofuqi的回复:
什么是存进去就乱码?存进哪里了?存了哪些字段值?“struts请求action”——这个我能理解成就是Http请求吗?publicstaticvoidcreatecustomer(RequestMessagermsg){System.out.println(rmsg);RequestMessagerequestMessage=newRequestMessage();//CRB创建账户StringtransCode="CRB";Stringchannel="ch";StringuserNO="ch";Stringpassword="123456";StringaccountNo=rmsg.getAccountNo();StringaccountName=rmsg.getAccountName();SimpleDateFormatdateFormat=newSimpleDateFormat("yyyyMMddHHmmssSSS");//可以方便地修改日期格式Datedate=newDate();Stringhehe=dateFormat.format(date);StringaliasAccount="changhw"+hehe;StringbankAllName=rmsg.getBankAllName();StringbankBranchName=rmsg.getBankBranchName();StringrecDepType=rmsg.getRecDepType();StringaccountProvince=rmsg.getAccountProvince();StringaccountCity=rmsg.getAccountCity();StringbusiTransNO=getUUID();StringrequestTime=DateTools.getDate("yyyy-MM-ddHH:mm:ss.SSS");Stringsign=MD5Utils.getMD5String(transCode+aliasAccount+channel+requestTime);requestMessage.setTransCode(transCode);requestMessage.setChannel(channel);requestMessage.setUserNO(userNO);requestMessage.setPassword(password);requestMessage.setAliasAccount(aliasAccount);requestMessage.setAccountNo(accountNo);requestMessage.setAccountName(accountName);requestMessage.setBankAllName(bankAllName);requestMessage.setBankBranchName(bankBranchName);requestMessage.setAccountProvince(accountProvince);requestMessage.setAccountCity(accountCity);requestMessage.setRecDepType(recDepType);requestMessage.setBusiTransNO(busiTransNO);requestMessage.setRequestTime(requestTime);requestMessage.setSign(sign);System.out.println(requestMessage);Stringcontent=JSON.toJSONString(requestMessage);System.out.println("明文内容为:"+content);StringsecurityContent=HttpsAuthTools.encrypt(content);System.out.println("密文内容为:"+securityContent);wfjHttpsSend(securityContent);}
这个方法后台执行通过main调用就可以实现但是通过action调用这个方法就不行了
哪一句代码打印乱码了?
我这是掉人家的接口人家那边存的是乱码!
解决方案八:
引用6楼qq526155988的回复:
Quote: 引用5楼gaofuqi的回复:
Quote: 引用4楼qq526155988的回复:
Quote: 引用3楼gaofuqi的回复:
什么是存进去就乱码?存进哪里了?存了哪些字段值?“struts请求action”——这个我能理解成就是Http请求吗?publicstaticvoidcreatecustomer(RequestMessagermsg){System.out.println(rmsg);RequestMessagerequestMessage=newRequestMessage();//CRB创建账户StringtransCode="CRB";Stringchannel="ch";StringuserNO="ch";Stringpassword="123456";StringaccountNo=rmsg.getAccountNo();StringaccountName=rmsg.getAccountName();SimpleDateFormatdateFormat=newSimpleDateFormat("yyyyMMddHHmmssSSS");//可以方便地修改日期格式Datedate=newDate();Stringhehe=dateFormat.format(date);StringaliasAccount="changhw"+hehe;StringbankAllName=rmsg.getBankAllName();StringbankBranchName=rmsg.getBankBranchName();StringrecDepType=rmsg.getRecDepType();StringaccountProvince=rmsg.getAccountProvince();StringaccountCity=rmsg.getAccountCity();StringbusiTransNO=getUUID();StringrequestTime=DateTools.getDate("yyyy-MM-ddHH:mm:ss.SSS");Stringsign=MD5Utils.getMD5String(transCode+aliasAccount+channel+requestTime);requestMessage.setTransCode(transCode);requestMessage.setChannel(channel);requestMessage.setUserNO(userNO);requestMessage.setPassword(password);requestMessage.setAliasAccount(aliasAccount);requestMessage.setAccountNo(accountNo);requestMessage.setAccountName(accountName);requestMessage.setBankAllName(bankAllName);requestMessage.setBankBranchName(bankBranchName);requestMessage.setAccountProvince(accountProvince);requestMessage.setAccountCity(accountCity);requestMessage.setRecDepType(recDepType);requestMessage.setBusiTransNO(busiTransNO);requestMessage.setRequestTime(requestTime);requestMessage.setSign(sign);System.out.println(requestMessage);Stringcontent=JSON.toJSONString(requestMessage);System.out.println("明文内容为:"+content);StringsecurityContent=HttpsAuthTools.encrypt(content);System.out.println("密文内容为:"+securityContent);wfjHttpsSend(securityContent);}
这个方法后台执行通过main调用就可以实现但是通过action调用这个方法就不行了
哪一句代码打印乱码了?
我这是掉人家的接口人家那边存的是乱码!
接口是wfjHttpsSend(securityContent);?