您的位置:首页 > 其它

搜索引擎地位及其发展历史

2013-08-11 08:05 197 查看
前几天在论坛发布了 关于 在tapestry 这中执行页面跳转 后乱码的问题,发现好几天都没有回复,诶现在的人好冷淡,俗话说的好啊求人不如求自己 开始查看 tapestry源代码
然后修改原来的页面跳转源代码,其实就是原来的
那句 throw new PageRedirectException(getErrorPage());
替换成下面这些采用自己的方式进行跳转其实就是为了修改编码GB2312 或者GBK 其实我测试什么都可以,哪怕随便输入一些字母都可以 但就是 UTF-8不可以不知道为什么,
页面无论才有什么编码都不行。。。晕死
最后查看页面发现,页面的文字都变成
下面的代码在网页里能显示成文字 但查看页面源代码可以发现下面这些问题是 & +# +5位的数字
分钟内系统不允许发送多
条供求信息

这些编码 在网上搜也没有搜到这些编码是什么格式希望有高手可以指点一二

经过再次查看源代码发现 BasePage 类有个方法
public ContentType getResponseContentType() {
return new ContentType("text/html");
}

就是这个方法的问题
在转向的页面覆盖此方法,就可以诶不用在写那么复杂的转向代码了 直接覆盖就可以了
public ContentType getResponseContentType() {
return new ContentType("text/html;charset=gb2312");
}


修改后的页面跳转代码
public void pageBeginRender(PageEvent event) {
int counts=getInformationService().getInformationDao().getCountsByType(InformationConstant.QUERY_INFORMATION_COUNTS_IN_TIME, this.getUserSession().getId(),null);
if(counts>0){
this.getErrorPage().setErrorMsg(InformationConstant.limitIssueTime+" 分钟内系统不允a许f发送多条供求信息!");
event.getRequestCycle().activate(getErrorPage());
try {
IRequestCycle cycle=event.getRequestCycle();
ContentType contentType = getErrorPage().getResponseContentType();
String encoding = contentType.getParameter("charset");
if (encoding == null)
{
encoding = cycle.getEngine().getOutputEncoding();

contentType.setParameter("charset", "gb2312");
}
PrintWriter printWriter = event.getRequestCycle().getInfrastructure().getResponse().getPrintWriter(contentType);
IMarkupWriter writer = event.getRequestCycle().getInfrastructure().getMarkupWriterSource().newMarkupWriter(printWriter, contentType);
cycle.renderPage(writer);
writer.close();

} catch (Exception e) {
e.printStackTrace();
}
//throw new PageRedirectException(getErrorPage());
}
}


修改前跳转代码

public void pageBeginRender(PageEvent event) {
int counts=getInformationService().getInformationDao().getCountsByType(InformationConstant.QUERY_INFORMATION_COUNTS_IN_TIME, this.getUserSession().getId(),null);
if(counts>0){
this.getErrorPage().setErrorMsg(InformationConstant.limitIssueTime+" 分钟内系统不允许发送多条供求信息!");
throw new PageRedirectException(getErrorPage());
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: