级联利用Ajax取值第二级,找不到发送的SQLID。

小沙弥图图 发布于 2016/08/31 09:55
阅读 142
收藏 0

环境一切正常。其他页面运行ajax正常,但在本页面控制器一致找不到sqlid,经检查,未发现同名的sqlid.

页面发送ajax代码如下:

<script language="javascript">
	$("#INSUID").change(function(){
		$.ajax({
			type:"post",
			url:"ajaxCommQuery.do?SYS_SQL_ID=F2001Q_PRODUCTINF_SECOND&SYS_CUT_PAGE=N&INSUID="+$("#INSUID").val(),
			dataType:"json",
			success:callback
		});
	});
	
	function callback(json){
		console.log(json);
		$("#PRODUCTNAME option:gt(0)").remove();
		$.each(json.rows,function(i,obj){
				$("#PRODUCTNAME").append("<option value='"+obj.PRODUCTID+"'>"+obj.PRODUCTNAME+"</option>");  
		  	});
	}
</script>

controller代码:

@RequestMapping(value = "/ajaxCommQuery.do")
	@ResponseBody
	public String commAjaxQuery(HttpServletRequest request, HttpServletResponse response){
		params = RequestUtil.getParameters();
		
		//1.获取请求参数
		String sqlId = (String)request.getParameter("SYS_SQL_ID");
		String isCutPage = (String)request.getParameter("SYS_CUT_PAGE");
		
		Integer pageNum = Integer.valueOf(String.valueOf(request.getParameter("pageNum")==null?pageBo.getPageNum():request.getParameter("pageNum")));
		Integer pageSize = Integer.valueOf(String.valueOf(request.getParameter("numPerPage")==null?pageBo.getPageSize():request.getParameter("numPerPage")));
		
		String menuId  = (String)request.getParameter("menu_id");
		//3.业务处理
		if(!Utility.isNull(sqlId)){
			SqlXmlConfigExeBo exeBo = null;
			try {
				exeBo = (SqlXmlConfigExeBo)CacheUtility.getFromCache(Global.SQL_CACHE_PREFIX+sqlId);
			} catch (NeedsRefreshException e) {
				log.error("sqlId:"+sqlId,e);
				return "";
			}
			
			String validRet = service.sqlExecuteValid(exeBo, params);
			if(!"0000".equals(validRet)){
				return "";
			}
			
			Map<String, List<Map<String, Object>>> selectBatch = null;
			//判断是否进行分页,N-不分页
			if("N".equalsIgnoreCase(isCutPage)){
				selectBatch = service.selectBatch(exeBo.getSqlIdList(), params);
			}else{
				pageBo.setPageNum(pageNum);
				pageBo.setPageSize(pageSize);
				int totalCount = (Integer)service.select(menuId+"Q_COUNT", params).get(0);
				pageBo.setTotalCount(totalCount);
				selectBatch = service.selectBatch(exeBo.getSqlIdList(), params,pageBo.getStartIndex(),pageSize);
			}
			webRet.setmList(selectBatch);
			webRet.setqList(selectBatch.get(exeBo.getSqlIdList().get(0)));
		}
		return webRet.result2JsonList();
	}



sql.xml:

<select id="F2001Q_PRODUCTINF_SECOND" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
		select INSU_PRODUCTID,PRODUCTNAME,INSUNAME from t7_productinfo where INSUID=#INSUID#
	</select>

控制台:

[DEBUG] 2016-08-31 08:55:38,053 com.ibatis.common.logging.jakarta.JakartaCommonsLoggingImpl.debug(27) {conn-100094} Connection
[DEBUG] 2016-08-31 08:55:38,053 com.ibatis.common.logging.jakarta.JakartaCommonsLoggingImpl.debug(27) {conn-100094} Preparing Statement:    SELECT 1 as page_count   
[DEBUG] 2016-08-31 08:55:38,053 com.ibatis.common.logging.jakarta.JakartaCommonsLoggingImpl.debug(27) {pstm-100095} Executing Statement:    SELECT 1 as page_count   
[DEBUG] 2016-08-31 08:55:38,053 com.ibatis.common.logging.jakarta.JakartaCommonsLoggingImpl.debug(27) {pstm-100095} Executing Statement:    SELECT 1 as page_count   
[DEBUG] 2016-08-31 08:55:38,053 com.ibatis.common.logging.jakarta.JakartaCommonsLoggingImpl.debug(27) {pstm-100095} Parameters: []
[DEBUG] 2016-08-31 08:55:38,053 com.ibatis.common.logging.jakarta.JakartaCommonsLoggingImpl.debug(27) {pstm-100095} Parameters: []
[DEBUG] 2016-08-31 08:55:38,057 com.ibatis.common.logging.jakarta.JakartaCommonsLoggingImpl.debug(27) {pstm-100095} Types: []
[DEBUG] 2016-08-31 08:55:38,057 com.ibatis.common.logging.jakarta.JakartaCommonsLoggingImpl.debug(27) {pstm-100095} Types: []
[DEBUG] 2016-08-31 08:55:38,057 com.ibatis.common.logging.jakarta.JakartaCommonsLoggingImpl.debug(27) {conn-100097} Connection
[DEBUG] 2016-08-31 08:55:38,057 com.ibatis.common.logging.jakarta.JakartaCommonsLoggingImpl.debug(27) {conn-100097} Preparing Statement:    select INSUID,INSUNAME,TEL,INSUSTATE,LINKMAN,HANDFLAG,ADD_DATE from t7_insurer   
[DEBUG] 2016-08-31 08:55:38,057 com.ibatis.common.logging.jakarta.JakartaCommonsLoggingImpl.debug(27) {pstm-100098} Executing Statement:    select INSUID,INSUNAME,TEL,INSUSTATE,LINKMAN,HANDFLAG,ADD_DATE from t7_insurer   
[DEBUG] 2016-08-31 08:55:38,057 com.ibatis.common.logging.jakarta.JakartaCommonsLoggingImpl.debug(27) {pstm-100098} Executing Statement:    select INSUID,INSUNAME,TEL,INSUSTATE,LINKMAN,HANDFLAG,ADD_DATE from t7_insurer   
[DEBUG] 2016-08-31 08:55:38,061 com.ibatis.common.logging.jakarta.JakartaCommonsLoggingImpl.debug(27) {pstm-100098} Parameters: []
[DEBUG] 2016-08-31 08:55:38,061 com.ibatis.common.logging.jakarta.JakartaCommonsLoggingImpl.debug(27) {pstm-100098} Parameters: []
[DEBUG] 2016-08-31 08:55:38,061 com.ibatis.common.logging.jakarta.JakartaCommonsLoggingImpl.debug(27) {pstm-100098} Types: []
[DEBUG] 2016-08-31 08:55:38,061 com.ibatis.common.logging.jakarta.JakartaCommonsLoggingImpl.debug(27) {pstm-100098} Types: []
[INFO] 2016-08-31 08:55:38,065 com.rshz.web.platfrom.action.CommWebTransController.commQuery(146) Request query nav path:\pages\F2\F2001-L
######### interceptor Session 过期。。
[ERROR] 2016-08-31 08:55:39,497 com.rshz.web.platfrom.action.CommWebTransController.commAjaxQuery(404) sqlId:F2001Q_PRODUCTINF_SECOND
com.opensymphony.oscache.base.NeedsRefreshException
	at com.opensymphony.oscache.base.Cache.getFromCache(Cache.java:325)
	at com.opensymphony.oscache.base.Cache.getFromCache(Cache.java:199)
	at com.opensymphony.oscache.general.GeneralCacheAdministrator.getFromCache(GeneralCacheAdministrator.java:132)
	at com.rshz.web.platfrom.util.CacheUtility.getFromCache(CacheUtility.java:55)
	at com.rshz.web.platfrom.action.CommWebTransController.commAjaxQuery(CommWebTransController.java:402)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at com.rshz.web.platfrom.filter.MyFilter.doFilter(MyFilter.java:99)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1082)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:623)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)





加载中
0
小沙弥图图
历经6位大神排错,终于再下一城,发现在项目属性中java builder没有勾选。
0
小沙弥图图
如果没有Java builder ,Ajax 发送的请求,controller是无法处理的,因此返回值json一直未null,勾选Java builder 后,运行正常,但在此去掉 Java builder 也是可以挣正常运行的,目前来看Javabuilder只是初始化一次,后即使未勾选亦可正常运行。
返回顶部
顶部