pager的getFirstParam为什么写成pager.firstParam?
是哪里做了转换吗?依据是什么?
为什么我的会报如下错误?
E:\tomcat\bin\catalina.bat run [2018-10-02 01:40:58,719] Artifact shopmgr1:war exploded: Waiting for server connection to start artifact deployment... Using CATALINA_BASE: "C:\Users\Administrator\.IntelliJIdea2018.1\system\tomcat\Unnamed_shopmgr1" Using CATALINA_HOME: "E:\tomcat" Using CATALINA_TMPDIR: "E:\tomcat\temp" Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_171" Using CLASSPATH: "E:\tomcat\bin\bootstrap.jar;E:\tomcat\bin\tomcat-juli.jar" 02-Oct-2018 13:41:00.731 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.5.32 02-Oct-2018 13:41:00.738 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jun 20 2018 19:50:35 UTC 02-Oct-2018 13:41:00.738 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.5.32.0 02-Oct-2018 13:41:00.738 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 7 02-Oct-2018 13:41:00.738 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 6.1 02-Oct-2018 13:41:00.738 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64 02-Oct-2018 13:41:00.739 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jdk1.8.0_171\jre 02-Oct-2018 13:41:00.739 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_171-b11 02-Oct-2018 13:41:00.739 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation 02-Oct-2018 13:41:00.739 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\Administrator\.IntelliJIdea2018.1\system\tomcat\Unnamed_shopmgr1 02-Oct-2018 13:41:00.740 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: E:\tomcat 02-Oct-2018 13:41:00.741 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\Administrator\.IntelliJIdea2018.1\system\tomcat\Unnamed_shopmgr1\conf\logging.properties 02-Oct-2018 13:41:00.741 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 02-Oct-2018 13:41:00.741 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote= 02-Oct-2018 13:41:00.742 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099 02-Oct-2018 13:41:00.742 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false 02-Oct-2018 13:41:00.742 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false 02-Oct-2018 13:41:00.744 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1 02-Oct-2018 13:41:00.744 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048 02-Oct-2018 13:41:00.744 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources 02-Oct-2018 13:41:00.746 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs= 02-Oct-2018 13:41:00.746 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\Administrator\.IntelliJIdea2018.1\system\tomcat\Unnamed_shopmgr1 02-Oct-2018 13:41:00.747 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=E:\tomcat 02-Oct-2018 13:41:00.747 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=E:\tomcat\temp 02-Oct-2018 13:41:00.747 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk1.8.0_171\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.8.0_171;E:\imooc资料\apache-maven-3.5.4\bin;C:\Program Files\MySQL\MySQL Server 8.0\bin;.] 02-Oct-2018 13:41:01.033 信息 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"] 02-Oct-2018 13:41:01.065 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read 02-Oct-2018 13:41:01.081 信息 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"] 02-Oct-2018 13:41:01.085 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read 02-Oct-2018 13:41:01.086 信息 [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1107 ms 02-Oct-2018 13:41:01.143 信息 [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina] 02-Oct-2018 13:41:01.143 信息 [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.32 02-Oct-2018 13:41:01.164 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"] 02-Oct-2018 13:41:01.197 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"] 02-Oct-2018 13:41:01.202 信息 [main] org.apache.catalina.startup.Catalina.start Server startup in 115 ms Connected to server [2018-10-02 01:41:01,468] Artifact shopmgr1:war exploded: Artifact is being deployed, please wait... 02-Oct-2018 13:41:05.017 信息 [RMI TCP Connection(2)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. [2018-10-02 01:41:07,953] Artifact shopmgr1:war exploded: Artifact is deployed successfully [2018-10-02 01:41:07,953] Artifact shopmgr1:war exploded: Deploy took 6,485 milliseconds 02-Oct-2018 13:41:11.167 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [E:\tomcat\webapps\manager] 02-Oct-2018 13:41:11.467 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [E:\tomcat\webapps\manager] has finished in [298] ms 登录成功 org.springframework.jdbc.BadSqlGrammarException: ### Error querying database. Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0,3' at line 2 ### The error may exist in com/imooc/shop/repository/ArticleMapper.xml ### The error may involve defaultParameterMap ### The error occurred while setting parameters ### SQL: select * from ec_article WHERE LIMIT ?,? ### Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0,3' at line 2 ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0,3' at line 2 at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:231) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371) at com.sun.proxy.$Proxy14.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:198) at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52) at com.sun.proxy.$Proxy19.searchArticles(Unknown Source) at com.imooc.shop.service.ShopServiceImpl.searchArticles(ShopServiceImpl.java:71) at com.imooc.shop.action.ListServlet.getAll(ListServlet.java:75) at com.imooc.shop.action.ListServlet.service(ListServlet.java:46) at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0,3' at line 2 at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:975) at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:392) at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.execute(NewProxyPreparedStatement.java:1392) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:62) at com.sun.proxy.$Proxy22.execute(Unknown Source) at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:59) at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:73) at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:60) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:137) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:96) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:77) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358) ... 32 more
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.imooc.shop.repository.ArticleMapper"> <select id="searchArticles" resultType="Article"> <!--别名配置 ,是由spring配置得到简化的,否则要写全路径--> select * from ec_article <where> <if test="typeCode!=null&&typeCode!=''"> and TYPE_CODE like CONCAT("",#{typeCode},"%") </if> <if test="secondType!=null&&secondType!=''"> and TYPE_CODE =#{secondType} </if> <if test="title!=null&&title!=''"> and title like CONCAT("%",#{title},"%") </if> LIMIT #{pager.firstParam},#{pager.pageSize} </where> </select> <select id="count" resultType="int"> <!--别名配置 ,是由spring配置得到简化的,否则要写全路径--> select count(*) from ec_article <where> <if test="typeCode!=null&&typeCode!=''"> and TYPE_CODE like CONCAT("",#{typeCode},"%") </if> <if test="secondType!=null&&secondType!=''"> and TYPE_CODE =#{secondType} </if> <if test="title!=null&&title!=''"> and title like CONCAT("%",#{title},"%") </if> </where> </select> </mapper>
package com.imooc.shop.repository; import com.imooc.shop.bean.Article; import com.imooc.shop.bean.ArticleType; import com.imooc.shop.utils.Pager; import org.apache.ibatis.annotations.Param; import java.util.List; public interface ArticleMapper { List<Article> searchArticles(@Param("typeCode")String typeCode,@Param("secondType") String secondType,@Param("title") String title, @Param("pager")Pager pager); int count(@Param("typeCode")String typeCode,@Param("secondType") String secondType,@Param("title") String title); }
0
收起
正在回答 回答被采纳积分+1
4回答
似乎有点意思
2018-10-03 19:02:37
### Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0,3' at line 2
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0,3' at line 2
看异常信息,问题出在sql语句的limit部分
SSM主流框架入门与综合项目实战2018版
- 参与学习 人
- 提交作业 205 份
- 解答问题 4317 个
Java中非常实用的SSM整合开发内容,从Spring开始,到MyBaits的进阶内容,再到SpringMVC的应用,最后是SSM整合开发案例,逐步深入,助你成长为一名Java工程师!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星