SpringRoo自定义查找器

SpringRoo自定义查找器,第1张

Spring / Roo自定义查找

好吧,采用老式的方法… Java中的Servlets标准定义了带有参数的Map(哈希,字典)所在的Request对象,因此您可以通过以下方式访问它们:

public ModelAndView searchAssets(HttpRequest request) {    StringBuilder builder = new StringBuilder();    for (String param : request.getParameterNames()) {        value = request.getParameter(param);        builder.append(param);        builder.append("="); // or LIKE        builder.append("'" + value "'");        builder.append(" AND ");    }    // deleting the last " AND "    builder.delete(builder.length-5, builder.length);    // In the entity create a method that executes a query with the string    // If the parameter names are column names then you'd have to use a nativeQuery    // You'd have to look it up in JPA   List<Asset> list = Asset.search(builder.toString());   // put the list in the ModelAndView}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5166926.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-18
下一篇 2022-11-18

发表评论

登录后才能评论

评论列表(0条)

保存