在线等,大家帮帮忙啊?mybatis 分页是能不能传多个参数包括排序时用的关键字(asc或desc)
我以前是仅仅分页,排序是手动赋值的,没有问题:
接口
public List<FuZhuang> showalldescdesc1(@Param("offset") int offset, @Param("limit") int limit);
sql语句
<select id="showalldescdesc1" resultType="FuZhuang" >
SELECT * from fuzhuang order by price desc,yuexiaoliang desc LIMIT #{offset},#{limit};
</select
但是现在想先排序时传入参数(asc、desc):
接口
public List<FuZhuang> showalldescdesc1(@Param("offset") int offset, @Param("limit") int limit,@Param("str") String str);
sql语句
<select id="showalldescdesc1" resultType="FuZhuang" >
SELECT * from fuzhuang order by price #{str},yuexiaoliang desc LIMIT #{offset},#{limit};
</select>
结果报错了:
org.springframework.jdbc.BadSqlGrammarException:
### Error querying database. Cause:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 ''desc',yuexiaoliang desc LIMIT 6,6' at line 1
### The error may exist in mybatis/mappers/FuZhuangMapper.xml
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT * from fuzhuang order by price ?,yuexiaoliang desc LIMIT ?,?;
### Cause: com.mysql.jdbc.exceptions.jdbc4.My
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 ''desc',yuexiaoliang desc LIMIT 6,6' at line 1
; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 ''desc',yuexiaoliang desc LIMIT 6,6' at line 1
org.springframework.jdbc.support.SQLErrorCode
SQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:233)
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71)
org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365)
$Proxy10.selectList(Unknown Source)
org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:195)
org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:124)
org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.jav