第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

為啥就是輸不出所需時(shí)間嘞???

我用的eclipse配置都弄了,也能輸出就是不能輸出時(shí)間???求教。

struts.xml
<?xml?version="1.0"?encoding="UTF-8"?>
<!--?指定Strust配置文件的DTD信息?-->
<!DOCTYPE?struts?PUBLIC
		"-//Apache?Software?Foundation//DTD?Struts?Configuration?2.3//EN"
		"http://struts.apache.org/dtds/struts-2.3.dtd">
<!--?指定Struts2配置文件的根元素?-->
<struts>
	<package?name="default"??namespace="/"??extends="struts-default">
		
		<!--?注冊攔截器?-->
		<interceptors>
			<interceptor?name="mytimer"?class="com.imooc.interceptor.TimerInterceptor"></interceptor>
		</interceptors>
		<action?name="timer"?class="com.imooc.action.TimerAction">
			<result>/success.jsp</result>
			<!--?引用攔截器?-->
			<interceptor-ref?name="mytimer"></interceptor-ref>
		</action>
		
	</package>
</struts>

TimerAction.java
package?com.imooc.action;

import?com.opensymphony.xwork2.ActionSupport;

public?class?TimerAction?extends?ActionSupport?{

	@Override
	public?String?execute()?throws?Exception?{
		for(int?i=0;?i<10000;i++){
			System.out.println("陳京輝");
		}
		return?SUCCESS;
	}
	
}

TimerInterceptor.java
package?com.imooc.interceptor;

import?com.opensymphony.xwork2.ActionInvocation;
import?com.opensymphony.xwork2.interceptor.AbstractInterceptor;

/*
?*?計(jì)算Action花費(fèi)時(shí)間
?*/
public?class?TimerInterceptor?extends?AbstractInterceptor?{

	@Override
	public?String?intercept(ActionInvocation?invocation)?throws?Exception?{
		//1.執(zhí)行Action之前
		long?start?=?System.currentTimeMillis();
		//2.執(zhí)行下一個(gè)攔截器,如果已經(jīng)是最后一個(gè)攔截器,則執(zhí)行目標(biāo)Action
		String?result?=?invocation.invoke();
		//3.執(zhí)行Action之后
		long?end?=?System.currentTimeMillis();
		System.out.println("執(zhí)行Action花費(fèi)的時(shí)間:"?+?(end?-?start)?+?"ms");
		return?result;
	}

}


正在回答

2 回答

攔截器不僅要在struts.xml注冊,也要在web.xml里注冊

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

qq_我有一個(gè)方丈師兄_0

???
2018-08-09 回復(fù) 有任何疑惑可以回復(fù)我~

輸不出什么?

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

京飛 提問者

花費(fèi)的時(shí)間就是(end - start)這個(gè)值。。。
2017-05-19 回復(fù) 有任何疑惑可以回復(fù)我~
#2

慕數(shù)據(jù)5111453 回復(fù) 京飛 提問者

那有什么結(jié)果輸出嗎? 有沒有報(bào)錯(cuò)
2017-05-20 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

為啥就是輸不出所需時(shí)間嘞???

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號