Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get data from spring controller without annotation

Tags:

java

spring

i am using Spring 3.x for my MVC application without annotation. I want to get data only not view . I google it and found it is possible using @ResponseBody . but i dont want to use annotation. how can i tell spring it is only data not a view without annotation. my sample code given below .

public class ShowGraphController extends AbstractController {

    private JdbcUserDao userDao;

    public void setUserDao(JdbcUserDao userDao) {
        this.userDao = userDao;
    }

    protected ModelAndView handleRequestInternal(HttpServletRequest request,HttpServletResponse responce) throws Exception {{
        return new  ModelAndView("want it retun as a data not a view name only");
    }
}
like image 837
krish Avatar asked Mar 09 '26 02:03

krish


1 Answers

I assume you mean JSON when you say data?

If you have to use ModelAndView style just handle the HttpServletResponse yourself and return null.

like image 111
Adam Gent Avatar answered Mar 11 '26 01:03

Adam Gent



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!