报错!

03-11-11 tesge
压力测试,多线程访问时报错: java.lang.IllegalStateException: Cannot forward a response that is already committed

请问是怎么回事,急

raynix
2003-11-11 11:02
如果一个response的状态是commited,也就是说调用过flushBuffer(),那么将此response forward就抛出你看到的异常。

tesge
2003-11-11 11:25
不太明白,我得系统只有一个类b的实例,它调用了别的类来进行数据库操作,然后再forward请求到jsp页面,是不是没有同步所以产生上面得错误呀!急

raynix
2003-11-11 12:08
你是头一回上论坛吗?你不贴相关代码和完整的stacktrace,神仙能帮你。

tesge
2003-11-11 13:38
工厂类中生成command类的方法: 如果我不把command缓存到mapClass这个hashtalbe中就不会报上面的错,可我觉得缓存起来性能可能会好些。

public Command createCommand(String actionName) {

Command command;

try {

command = (Command)mapClass.get(actionName) ;

if(null == command)

{

Class obj = Class.forName(actionName);

command = (Command) obj.newInstance();

mapClass.put(actionName, command);

DebugLog .debug

}

}

catch (Exception ex) {

return null;

}

return command;

}

Command 方法:

public class NbdwCommand

extends Command {

DebugLog log = DebugLog.getInstance();

ErrorMessage message = ErrorMessage.getInstance();

boolean result = false;

Class prog = NbdwCommand.class;

public void execute() {

String actionId = (String) requester.getAttribute(GlobalCONST.ACTIONID);

m_url = (String) requester.getAttribute(GlobalCONST.PAGERES);

DB db = new DB();

try {

//list操作

if (actionId.equals(GlobalCONST.Glob_List)) {

//得到需要显示的页号

String strPageNo = request.getParameter("pageNo");

//默认返回值为1

pageNo = MathUtil.getPageNo(strPageNo);

NbdwWebImp webImp = new NbdwWebImp();

//得到当前页的记录

HashList list = new HashList(GlobalCONST.PAGE_SIZE);

String actionRes = request.getParameter("actionRes");

String sql = "";

String sqlTotal = "";

if (actionRes.equals("cj_nbdw_list")) {

sql = " select dw.* from njc_nbdw dw ,sys_yh yh where dw.zzmj=yh.yonghubianhao and dw.zzmj='" +

"160" + "'";

sqlTotal = "select count(*) as cnt from njc_nbdw dw where dw.zzmj='" +

"160" + "'";

}

else if (actionRes.equals("cx_nbdw_list")) {

sql = getSql();

sqlTotal = "select count(*) as cnt from njc_nbdw dw,sys_zz zz where " +

getWhere();

}

list = webImp.selectNbdw(db, sql, sqlTotal, GlobalCONST.PAGE_SIZE,pageNo);

int max = list.maxNum;

//得到共有多少页

totalPage = ( (Integer) (list.getRow(list.maxNum - 1).get("totalPage"))).

intValue();

if(totalPage ==0)

list = new HashList(0);

request.setAttribute("pageNo", "" + pageNo);

request.setAttribute("totalPage", "" + totalPage);

//修改

//request.setAttribute("pageAction",actionId);

request.setAttribute("pageAction", actionRes);

request.setAttribute("list", list);

}

....

finally

{

db.close();

forward(m_url);

}

}

猜你喜欢
2Go 1 2 下一页