因为JFinal 把Dao去掉了,于是我开发中大量使用了Db模式,很方便。
今天想设定个全局变量SQL,其它action调用时候可以拼接SQL语句,访问这个action就报错了,而且没有进入action。
public class UserController{ /** * 三表联接 */ StringBuffer sql = new StringBuffer("SELECT * " + " FROM teacher t, m_teacher_student m, student s " + " WHERE t.id = m.teacher AND m.student = s.id ");
public void showExamStudents(){ this.sql.append(" and s.id = '" + getUserId() + "' "); } }
报错信息:
[ERROR]-[Thread: qtp5778967-24]-[com.jfinal.core.ActionHandler.handle()]: /teacher/showExamStudents
java.lang.NullPointerException
at com.jfinal.core.Controller.getCookieObject(Controller.java:454)
at com.jfinal.core.Controller.getCookie(Controller.java:407)
at com.jfinal.core.Controller.getCookie(Controller.java:415)
at com.bdschool.evaluate.controler.TeacherController.<init>(TeacherController.java:123)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at java.lang.Class.newInstance(Class.java:374)
at com.jfinal.core.ActionHandler.handle(ActionHandler.java:68)
at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:453)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:365)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:926)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:988)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:635)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:724)
估计是@JFinal不允许有那么些额外的参数吧!那个可以加上吗?
你这个没看懂要干什么不好意思,偷了个懒,刚修改了下代码,现在能看清了吧sql有错误,例如这样的都有错误:"WHEREt.id=m.teacherANDm.student=s.id",用引号将s.id这样的值引起来了,那么这就是常量,而应该这样:"WHEREt.id=?ANDm.student=?"
用and写关联查询。。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。