I am getting:
Cannot get property 'show' on null object in my grails project
Here is my code
package com.djamware class TestController { EmployeeService employeeService def secondaryDataSourceTemplate def mainDataSourceTemplate def testService static allowedMethods = [save: "POST", update: "PUT", delete: "DELETE"] def index() { render testService.show } def show() { Employee employee=new Employee(); employee.setName("Gaurav chauhan") employee.setEmail("[email protected]") employee.setPosition("Java Devloper") employee.setSalary(new Double(15000.0)) String sqlQuery = "SELECT name FROM Employee"; def counti=new Integer(1); try { def result = secondaryDataSourceTemplate.queryForList(sqlQuery) println "result of Query is =====>"+result.name println "Size of Result ========> "+result.size(); counti=result.size(); } catch (Exception e) { e.printStackTrace(); counti=new Integer(10); } employeeService.save(employee) render counti; } }
Try including into your static methods the definition for show
show
static allowedMethods = [show: "GET", save: "POST", update: "PUT", delete: "DELETE"]
2.1m questions
2.1m answers
60 comments
57.0k users