|
1、在.w文件的js中调用baas请求,其中selectData是select控件绑定的data,自动加载代码如下:
- var Model = function() {
- this.callParent();
- this.actionUrl = "/baas/takeoutAdmin/attachment/SimpleFileStore";
- alert("1");
- justep.Baas.sendRequest({
- "url" : "/KS/gan",
- "action" : "getUser",
- "async" : true,
- "success" : function(ret) { this.comp('selectData').loadData(ret);
- }
- });
- alert("2");
- };
复制代码
2、在baas下有个文件夹KS,里面有个gan.service.m文件,我在这个里面增加了一个action,其实现为:KS.Api.getUser;同时在KS目录下,有个Api.java文件,里面代码如下(使用数据库的名称为KS):
- package KS;
- import java.sql.Connection;
- import java.util.ArrayList;
- import java.util.List;
- import javax.naming.NamingException;
- import com.alibaba.fastjson.JSONObject;
- import com.justep.baas.action.ActionContext;
- import com.justep.baas.data.DataUtils;
- import com.justep.baas.data.Table;
- import com.justep.baas.data.Transform;
- import com.justep.baas.data.sql.SQLException;
- public class Api {
- public static JSONObject getUser(JSONObject params, ActionContext context) throws SQLException, NamingException, java.sql.SQLException {
-
- // List<Object> sqlParams = new ArrayList<Object>();
- Table table = null;
- Connection conn = context.getConnection("KS");
- System.out.println(conn);
- String sql = "";
- try{
- sql = "SELECT distinct id FROM gan ";
- table = DataUtils.queryData(conn, sql, null, null, null, null);
- return Transform.tableToJson(table);
-
- } finally {
- conn.close();
- }
- }
- }
复制代码
最后运行出了如下错误,请问大神们,这是怎么回事,求指点,O(∩_∩)O谢谢
java.lang.NullPointerException
at com.justep.baas.servlet.BaasServlet.execService(Unknown Source)
at com.justep.baas.servlet.BaasServlet.service(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:745)
八月 11, 2016 6:06:40 下午 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet WeX5_Baas_Servlet threw exception
java.lang.NullPointerException
at com.justep.baas.servlet.BaasServlet.execService(Unknown Source)
at com.justep.baas.servlet.BaasServlet.service(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:745)
|
|