0

I made a simple app using spring framework i want to pass class object from controller(backend) to frontend

backend code

@RequestMapping("/searchBook.htm")
    public ModelAndView searchBook(HttpServletRequest request,
            HttpServletResponse response) throws Exception 
    {
        Fruit f = new Fruit();

        f.setName("apple"); 
        f.setPrice(20);

        request.setAttribute("fruit",f);
}

frontend :

${fruit.name}

what's the best way to pass class object from backend to frontend ?

shubham goel
  • 41
  • 1
  • 6
  • Welcome to Stack Overflow! Please take the [tour](http://stackoverflow.com/tour), have a look around, and read through the [help center](http://stackoverflow.com/help), in particular [How do I ask a good question?](http://stackoverflow.com/help/how-to-ask) and [What topics can I ask about here?](http://stackoverflow.com/help/on-topic). - what is your exact problem? – Timothy Truckle Mar 31 '17 at 17:28
  • `throws Exception` is redundant and an antipattern. – Lew Bloch Mar 31 '17 at 17:29

0 Answers0