JFinal WeiXin在工作环境中部署没问题,可是在服务器中部署报错

Aenocyon 发布于 2014/12/20 12:47
阅读 811
收藏 0

@JFinal 你好,想跟你请教个问题:我Tomcat中报错:找不到指定模板,是什么意思,开发环境中使用正常,换一台服务器就报这个错误。


JFinal action report -------- 2014-12-20 12:35:22 ------------------------------

Controller  : com.weixin.demo.WeixinMsgController.(WeixinMsgController.java:1)
Method      : index
Interceptor : com.weixin.sdk.jfinal.MsgInterceptor.(MsgInterceptor.java:1)
Parameter   : timestamp=1419050120  encrypt_type=aes  nonce=17298729  msg_signat
ure=162aa21fd95c2c92ad6341e7f302d13e33cd1ed2  signature=b250ae86c3a1dfca8972ffb7
8d84e2a66b69063a
--------------------------------------------------------------------------------

接收消息:
<xml>
    <ToUserName><![CDATA[gh_da265607ba8f]]></ToUserName>
    <FromUserName><![CDATA[ornYguInOgNLQTdsrTRutg4ODGPE]]></FromUserName>
    <CreateTime>1419050120</CreateTime>
    <MsgType><![CDATA[text]]></MsgType>
    <Content><![CDATA[录入信息]]></Content>
    <MsgId>6094773856987092810</MsgId>
    <Encrypt><![CDATA[vuF/fVv+Z9pyl7nmqaj6DXoHfMpF0S114YHwdD+ZefXMc5cb7l+dAJYx22
W2VSjMLRhEyhIO6Nps0lXAddhKtzC47nFK01RBoJjC94JsEnZZWMIzCdPs6zgvLf7ZmH8IK9zf7Ecpof
qtYDCA3K7sBxABURP0tMbwjOpHvnbrZmzHWVzynET6lhJ/W1v/rHqt5eBYI0Ytk7tAwQ4ptszLE5sey7
mOgmzOO4Z/+RXwLOB3/uIE/X+4Oltksep9Xbyojnm/shOLvSHsZBqO2iLSfb6zLw9tx8zo5p2DYIwPeA
8ltFPbqkRjk5e4R0Orb1x5NxnkgrSF6eXaZOTpDsZO9eZWGsEqFGldFPEyuQkDXM619XkZeXQB8bHwYi
DKCgzd6jI/qEeGY/7C99rcppIvK+9FQ63dzMwI2AL/hj6MdiWHtiLCm0yOmbPmnlgDHiNSiWe70yX+lo
i3MaNf9qvs4Q==]]></Encrypt>
</xml>

>>错找不到指定模板或者加载错(TEMPLATE_LOAD_ERROR): 位于0行 资源:/msg/index.html
模板根目录为 E:\apache-tomcat-workspace\webapps\ROOT\WEB-INF\weixin

 

加载中
0
JFinal
JFinal

引用来自“Aenocyon”的评论

引用来自“JFinal”的评论

贴出一下具体代码,以及错误堆栈,可能是你在 action 中没有  render,所以 jfinal 调用了默认的 render 方法,从而找不到模板

不好意思,出去了一趟,回复晚了,下面是WeixinMsgController.java中的processInTextMsg(InTextMsg inTextMsg)方法的代码

protected void processInTextMsg(InTextMsg inTextMsg) {
		String msgContent = inTextMsg.getContent().trim();
		int flag= 0;
		
		ActivityController activityController = new ActivityController();
		List<Activity> list = activityController.add();
		if (list.size() > 0) {
			for (int i = 0; i < list.size(); i++) {
				Activity ac = list.get(i);
				Activity activity = activityController.addbyid(ac.getBigDecimal("ids").toString());

				String activitykeyword = activity.getStr("activitykeyword");
				String activitytitle = activity.getStr("activitytitle");
				String activityintro = activity.getStr("activityintro");
				String activitypicurl = activity.getStr("activitypicurl");
				String activityurl = activity.getStr("activityurl");
				String activityflag = activity.getStr("activityflag");
				if (activitykeyword.indexOf(msgContent) != -1) {
					//文本
					if (activityflag.equals("1")) {
						OutTextMsg outTextMsg = new OutTextMsg(inTextMsg);
						outTextMsg.setContent(activityintro);
						render(outTextMsg);
						flag = 1;
					}//图文
					else if (activityflag.equals("2")) {
						OutNewsMsg outNewMsg = new OutNewsMsg(inTextMsg);
						outNewMsg.addNews(activitytitle, activityintro, activitypicurl, activityurl);
						render(outNewMsg);
						flag = 2;
					}//音乐
					else if (activityflag.equals("3")) {
						OutMusicMsg outMusicMsg = new OutMusicMsg(inTextMsg);
						outMusicMsg.setTitle(activitytitle);
						outMusicMsg.setDescription(activityintro);
						outMusicMsg.setMusicUrl(activityurl);
						outMusicMsg.setHqMusicUrl(activityurl);
						outMusicMsg.setFuncFlag(true);
						render(outMusicMsg);
						flag = 3;
					}
				}
			}
			if (flag == 0) {
				OutTextMsg outMsg = new OutTextMsg(inTextMsg);
				outMsg.setContent("\t文本消息已成功接收,内容为: " + inTextMsg.getContent() + "\n\n" + helpStr);
				render(outMsg);
				flag = 0;
			}
		}
	}



错误很明显,if (list.size() > 0) 这个判断如果是 false,那么整个流程就没有执行过 render 方法,所以 jfinal 会设计用默认 render(template),其中: template = viewPath + methodName + 模板扩展名,所以就调用了:render("/msg/index.html");
0
JFinal
JFinal
贴出一下具体代码,以及错误堆栈,可能是你在 action 中没有  render,所以 jfinal 调用了默认的 render 方法,从而找不到模板
0
A
Aenocyon

引用来自“JFinal”的评论

贴出一下具体代码,以及错误堆栈,可能是你在 action 中没有  render,所以 jfinal 调用了默认的 render 方法,从而找不到模板

不好意思,出去了一趟,回复晚了,下面是WeixinMsgController.java中的processInTextMsg(InTextMsg inTextMsg)方法的代码

protected void processInTextMsg(InTextMsg inTextMsg) {
		String msgContent = inTextMsg.getContent().trim();
		int flag= 0;
		
		ActivityController activityController = new ActivityController();
		List<Activity> list = activityController.add();
		if (list.size() > 0) {
			for (int i = 0; i < list.size(); i++) {
				Activity ac = list.get(i);
				Activity activity = activityController.addbyid(ac.getBigDecimal("ids").toString());

				String activitykeyword = activity.getStr("activitykeyword");
				String activitytitle = activity.getStr("activitytitle");
				String activityintro = activity.getStr("activityintro");
				String activitypicurl = activity.getStr("activitypicurl");
				String activityurl = activity.getStr("activityurl");
				String activityflag = activity.getStr("activityflag");
				if (activitykeyword.indexOf(msgContent) != -1) {
					//文本
					if (activityflag.equals("1")) {
						OutTextMsg outTextMsg = new OutTextMsg(inTextMsg);
						outTextMsg.setContent(activityintro);
						render(outTextMsg);
						flag = 1;
					}//图文
					else if (activityflag.equals("2")) {
						OutNewsMsg outNewMsg = new OutNewsMsg(inTextMsg);
						outNewMsg.addNews(activitytitle, activityintro, activitypicurl, activityurl);
						render(outNewMsg);
						flag = 2;
					}//音乐
					else if (activityflag.equals("3")) {
						OutMusicMsg outMusicMsg = new OutMusicMsg(inTextMsg);
						outMusicMsg.setTitle(activitytitle);
						outMusicMsg.setDescription(activityintro);
						outMusicMsg.setMusicUrl(activityurl);
						outMusicMsg.setHqMusicUrl(activityurl);
						outMusicMsg.setFuncFlag(true);
						render(outMusicMsg);
						flag = 3;
					}
				}
			}
			if (flag == 0) {
				OutTextMsg outMsg = new OutTextMsg(inTextMsg);
				outMsg.setContent("\t文本消息已成功接收,内容为: " + inTextMsg.getContent() + "\n\n" + helpStr);
				render(outMsg);
				flag = 0;
			}
		}
	}



0
A
Aenocyon

引用来自“Aenocyon”的评论

引用来自“JFinal”的评论

贴出一下具体代码,以及错误堆栈,可能是你在 action 中没有  render,所以 jfinal 调用了默认的 render 方法,从而找不到模板

不好意思,出去了一趟,回复晚了,下面是WeixinMsgController.java中的processInTextMsg(InTextMsg inTextMsg)方法的代码

protected void processInTextMsg(InTextMsg inTextMsg) {
		String msgContent = inTextMsg.getContent().trim();
		int flag= 0;
		
		ActivityController activityController = new ActivityController();
		List<Activity> list = activityController.add();
		if (list.size() > 0) {
			for (int i = 0; i < list.size(); i++) {
				Activity ac = list.get(i);
				Activity activity = activityController.addbyid(ac.getBigDecimal("ids").toString());

				String activitykeyword = activity.getStr("activitykeyword");
				String activitytitle = activity.getStr("activitytitle");
				String activityintro = activity.getStr("activityintro");
				String activitypicurl = activity.getStr("activitypicurl");
				String activityurl = activity.getStr("activityurl");
				String activityflag = activity.getStr("activityflag");
				if (activitykeyword.indexOf(msgContent) != -1) {
					//文本
					if (activityflag.equals("1")) {
						OutTextMsg outTextMsg = new OutTextMsg(inTextMsg);
						outTextMsg.setContent(activityintro);
						render(outTextMsg);
						flag = 1;
					}//图文
					else if (activityflag.equals("2")) {
						OutNewsMsg outNewMsg = new OutNewsMsg(inTextMsg);
						outNewMsg.addNews(activitytitle, activityintro, activitypicurl, activityurl);
						render(outNewMsg);
						flag = 2;
					}//音乐
					else if (activityflag.equals("3")) {
						OutMusicMsg outMusicMsg = new OutMusicMsg(inTextMsg);
						outMusicMsg.setTitle(activitytitle);
						outMusicMsg.setDescription(activityintro);
						outMusicMsg.setMusicUrl(activityurl);
						outMusicMsg.setHqMusicUrl(activityurl);
						outMusicMsg.setFuncFlag(true);
						render(outMusicMsg);
						flag = 3;
					}
				}
			}
			if (flag == 0) {
				OutTextMsg outMsg = new OutTextMsg(inTextMsg);
				outMsg.setContent("\t文本消息已成功接收,内容为: " + inTextMsg.getContent() + "\n\n" + helpStr);
				render(outMsg);
				flag = 0;
			}
		}
	}



引用来自“JFinal”的评论

错误很明显,if (list.size() > 0) 这个判断如果是 false,那么整个流程就没有执行过 render 方法,所以 jfinal 会设计用默认 render(template),其中: template = viewPath + methodName + 模板扩展名,所以就调用了:render("/msg/index.html");

太感谢了,就是这个问题,我倒数据只导了个用户对象,没有数据,导致这个问题了,谢谢

返回顶部
顶部