Showing posts from October, 2011

Spring MVC- Redirect from one controller to another

In spring mvc its very easy to redirect from one controller to another controller

Example :

public class SpringController1{

public class SpringController2{

//thinking of redirecting on clicking on a method
@RequestMapping(value = "/", method = RequestMethod.POST, params = "action=cancel")
    public ModelAndView cancel(@ModelAttribute("MyForm") MyForm myForm, BindingResult errors,SessionStatus sessionStatus,HttpServletRequest request) throws MyException {
        ModelAndView modelAndView = new ModelAndView();

        //redirecting to controller1
        return new ModelAndView("redirect:/");



spring jdbc template rowmapper example

    public ArrayList getSearchResultByColumn_isAdmin(ABCResultForm  form, String roleId) {

        String query = StringConstants.ABC_RESULT_SEARCH_BY_COLUMN;
        System.out.println("Comes here getSearchResultByColumn");
        int count = 0;
                       query = query + " ORDER BY PROCESSING_DATE_START desc ";
                return (ArrayList) getJdbcTemplate().query(query,new Object[] {},new RowMapper() {
                            public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
                                String status;

                                if (rs.getString(4).equals("11"))
                                    status = "Error";
                                    status = "Ok/Warning";
                                ABCResultDataBean abcResultBean = new ABCResultDataBean(rs.getString(1), rs.getString(2), rs.getS…