Posts

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 :

@Controller
@RequestMapping("/springcontroller1")
public class SpringController1{
}



@Controller
public class SpringController2{

//thinking of redirecting on clicking on a method
@RequestMapping(value = "/SpringController2cancel.abc", 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();

        sessionStatus.setComplete();
        //redirecting to controller1
        return new ModelAndView("redirect:/springcontroller1.abc");


    }

}

spring jdbc template rowmapper example

@SuppressWarnings("unchecked")
    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";
                                else
                                    status = "Ok/Warning";
                                ABCResultDataBean abcResultBean = new ABCResultDataBean(rs.getString(1), rs.getString(2), rs.getS…