0

I want to create preview page i.e let us consider a registration form and before submit data to database user should see preview of data what they entered. i am using Spring mvc 3.0 and hibernate

=> this is my controller method, after submit it is going to database and inserting data and i am displaying that data on grid

@RequestMapping( value="/catalogue/create.action", method=RequestMethod.POST)
    public ModelAndView create(@ModelAttribute CatalogueBase catalogueForm) throws Exception {  

        ModelAndView mvc = null;
        try{

            List<CatalogueBase> catalogueBases =  new ArrayList<CatalogueBase>(); //getCatalogueBase(request);
            catalogueBases.add(catalogueForm);
            List<CatalogueBase> catalogueBaseList = catalogueService.create(catalogueBases);
            mvc =   new ModelAndView("catalogue/catalogueList");

        } catch (Exception e) {
            e.printStackTrace();
        }
        return mvc;
    }

=> now i kept one method it goes to preview page and if data is ok then it go to above method to insert into database

@RequestMapping( value="/catalogue/FormPreview.action", method=RequestMethod.POST)
    public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command) throws Exception {

            CatalogueBase catalogueBase = new CatalogueBase();

                // hear i setting only one value 

            request.setAttribute("titleNo", catalogueBase.getTitleNumber());

            return new ModelAndView("catalogue/catalogueFormPreview","catalogueBase",catalogueBase);

        }

and in jsp i gave EL like this ===== > ${catalogueBase.titleNo}

but it is getting null values

thanks in advance

4

1 回答 1

1

如果你设置为

request.setAttribute("titleNo", catalogueBase.getTitleNumber());

您应该在页面上以${titleNo}.

根据您的第二种方法,它应该为 null 因为您创建了新对象new CatalogueBase()

于 2013-07-24T23:40:26.927 回答