用tomcat运行web应用程序时,后台处理后的字符串,控制台打印出来是正常的,返回给页面的时候变成乱码,但是用glassfish运行又是正常的,glassfish的默认字符集是UTF-8,我将tomcat的字符集改为UTF-8,但是还是乱码,求大虾指教,感激不尽!
解决方案 »
- spring aop 方面的问题
- 怎么解决每次发布都存在新的问题(以前的功能,每次发布都有以前的功能出错)
- 如何将非纯文本格式的文件内容保存到数据库中
- 急!!!!用commons上传大文件遇到的问题!!!
- 请问用struts标签如何实现分页呢?请各位哥哥姐姐帮帮我吧!
- 在JSP中,文件的浏览次数或下载次数是怎么统计的?
- 一个文件上传和下载的程序,大家帮帮忙!!!!!!!!!!!
- 解决IE浏览器对ATGrid报表控件(Actviex控件)的拦截的方法
- 不错的兼职机会,每周末5小时,2000元/月,10小时 4000元/月
- 在JSP中两个页面之间如何传递参数?
- tomcat发布问题。
- 想在打开的第一页面上 浏览上方面的所有工具栏全不显示
<!--字符过滤 -->
<filter>
<filter-name>encode</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encode</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>
{ for (int i = 0; i < iCount; i++)
{ j7(y1.m_sMsgCode, sMsgCode[i]); j7(y1.m_sStatus, pcStauts);}y4;}int extractMsgCodeStatus(char* pcText, struct TMsgCodeStatus* ptMsgCodeStatus, int iCount)
{if (NULL == pcText || NULL == ptMsgCodeStatus){ return -1;}char J8[LengthOfGeneralString+1];
char* pcStart = pcText;int y5 = 0;int num = 0;int len = 0;int j = 0;int textLen = strlen(pcText);
for (int i = 0; i < textLen; i++){
if ((pcText[i] == ',') || (pcText[i] == ';')
|| (pcText[i] == '|') || (pcText[i] == ' ')
|| (pcText[i] == '/') || (pcText[i] == '\t'))
{
if ((y5 > 0) && (pcStart != NULL) && (num < iCount))
{
memset(J8, 0, sizeof(J8));
j6(J8, pcStart, y5);if (num >= iCount){ break;} len = strlen(J8); for (j = 0; j < len; j++)
{
if (J8[j] == ':')
{
memset(&(y2), 0, sizeof(TMsgCodeStatus));
j6(y2.m_sMsgCode, J8, j);
j6(y2.m_sStatus, J8 + j + 1, len - j - 1);
break;
}
}if (j == len){ return 0;}num++;
pcStart = (pcText + (i + 1));y5 = 0;
}
}else{y5++;}
}
if ((y5 > 0) && (pcStart != NULL) && (num < iCount))
{
J8[0] = '\0';j6(J8, pcStart, y5);J8[y5] = 0;len = strlen(J8);
for (j = 0; j < len; j++)
{if (J8[j] == ':')
{ memset(&(y2), 0, sizeof(TMsgCodeStatus));
j6(y2.m_sMsgCode, J8, j);
j6(y2.m_sStatus, J8 + j + 1, len - j - 1);
break;
} }if (j == len){return 0;}num++;
}return num;}
{
for (int i = 0; i < iCount && y1.m_sMsgCode[0] != '\0'; i++)
{
if (strcmp(y1.m_sMsgCode, tMsgCode) == 0) { j7(y1.m_sStatus, pcStatus);y4;}}y3;}char* TrimString(char* pcStr)
{if (NULL == pcStr){return NULL;} TGeneralString tmpStr;j7(tmpStr, pcStr); int i = 0;
for (i = 0; ' ' == tmpStr[i]; i++) ;for (int j = strlen(tmpStr) - 1; ' ' == tmpStr[j]; j--)
{ tmpStr[j] = '\0';} j7(pcStr, tmpStr + i);return pcStr;}// 功能:将字符串 pszSrc 以字符 ch 为分隔符的前缀拷贝到 dest 中
// 返回:指向 pszSrc 中第一次出现 ch 的指针。
// NULL表示在 src 没有出现 ch
char* GetPrefixByChar(const char* pszSrc, const char ch, string& sDest)
{const char* pStr;size_t prefix_len; pStr = strchr(pszSrc, ch); if (pStr == NULL)
{ sDest = pszSrc;}else{prefix_len = strlen(pszSrc) - strlen(pStr);
sDest.assign(pszSrc, prefix_len);}return const_cast<char*>(pStr);}string TrimString(string& sStr)
{const string delimiters = " \t";sStr.erase(sStr.find_last_not_of(delimiters) + 1);
sStr.erase(0, sStr.find_first_not_of(delimiters));return sStr;}string intToString(int iValue)
{ char buf[32];sprintf(buf, "%d", iValue);return string(buf);}
//处理空行
TBool IsBlankLine(const char* psLine){while (*psLine != '\0')
{if (*psLine == ' ' || *psLine == '\t'){psLine++; continue;}y3;}y4;}
//*: Filename: commfunc.hpp
#ifndef _COMMONFUN_HPP_#define _COMMONFUN_HPP_
#include "commondef.hpp"#include "writelog.hpp"#include <string>
#ifdef _SUN_UNIX using namespace std; #endif
#ifdef _AIX_UNIX
using namespace std;
#endif
class HOfstream;
TBool getOffsetDate(char* pDateAndTime, int iOffset, char* sOffsetDate);
TBool getCurDateAndTime(char* sCurrDate, char* sCurrTime);
time_t getTimeT(char* pDateAndTime);
//去掉字符串后面多余空格
TBool deleteExtraSpace(char* pString, int iSize);
char* GetPrefixByChar(const char* pszSrc, const char ch, string& sDest);
TBool isValidNum(const char* strToCheck);
//检查指定目录的有效性, 是否存在,是否可写,是否是目录,否则创建
TBool checkCreateDirectory(const char* sDirPath);
void printCodeBuff(char* pMsgBuff, int iMsgLen, HOfstream& tOut); //打印消息的码流
TBool initMsgCodeStatus(struct TMsgCodeStatus* ptMsgCodeStatus, char* pcStauts, TMsgCode* sMsgCode, int iCount);
int extractMsgCodeStatus(char* pcText, struct TMsgCodeStatus* ptMsgCodeStatus, int iCount);
TBool setMsgCodeStatus(struct TMsgCodeStatus* ptMsgCodeStatus, int iCount, TMsgCode tMsgCode, char* pcStatus);
char* TrimString(char* pcStr);
TBool IsBlankLine(const char* psLine);
string TrimString(string& sStr);
string intToString(int iValue);
#endif