Java Spring:该位置的参数不存在异常
我使用的是Spring框架,在下面的repository currentOrder方法中,我将日期作为参数发送,但当我使用该位置执行此参数时[1]不存在,引发异常 我正在发送以下网址 http://localhost:3000/api/orders/search/currentOrder?fromDate=2017-04-28&toDate=2017-05-02 我的代码中的错误在哪里Java Spring:该位置的参数不存在异常,java,spring,date,jpa,exception,Java,Spring,Date,Jpa,Exception,我使用的是Spring框架,在下面的repository currentOrder方法中,我将日期作为参数发送,但当我使用该位置执行此参数时[1]不存在,引发异常 我正在发送以下网址 http://localhost:3000/api/orders/search/currentOrder?fromDate=2017-04-28&toDate=2017-05-02 我的代码中的错误在哪里 public interface OrderRepository extends JpaRepository&
public interface OrderRepository extends JpaRepository<Order, Long> {
@PreAuthorize("hasAuthority('rights')")
@Query("Select o.orderDate from Order o where o.orderDate between fromDate and toDate")
List<Order> currentOrder(@Param("fromDate") Date fromDate,@Param("toDate") Date toDate);
}
查询中未使用您的参数。试着用:paramName来提及它们
也可以参考{fromDate}见它有效:D谢谢:'我能再问你一个问题吗?
@Query("Select o.orderDate from Order o where o.orderDate between :fromDate and :toDate")
List<Order> currentOrder(@Param("fromDate") Date fromDate,@Param("toDate") Date toDate);