Results 1 to 4 of 4

Thread: Problems with request between Controllers

  1. #1
    Join Date
    Jan 2011
    Posts
    4

    Default Problems with request between Controllers

    Hello, I'm very noob on spring and I'm having some problems passing parameters between controllers

    Here controller 1:

    @RequestMapping(method = RequestMethod.POST)
    public String onSubmit(@ModelAttribute("pedido") Pedido pedido, HttpServletRequest request)
    throws Exception
    {
    String login = (String) request.getSession().getAttribute("username");

    if ( WebUtils.hasSubmitParameter(request, "relatorio") )
    {
    request.setAttribute("pedido", pedido);
    return "redirect:Relatorio.html";
    }

    Controller 2:

    @RequestMapping(method = RequestMethod.GET)
    public String showUserForm (HttpServletRequest request)
    {
    Pedido pedido = (Pedido)request.getAttribute("pedido");


    The variable 'pedido' is always coming null when it shouldnt be. I tryied to use 'forward' instead of 'redirect' and I got this message:

    type Status report

    messageRequest method 'POST' not supported

    descriptionThe specified HTTP method is not allowed for the requested resource (Request method 'POST' not supported).

    Hope someone can help me.
    ps: sorry my english

  2. #2
    Join Date
    Jan 2011
    Posts
    4

    Default

    Anyone???????

  3. #3
    Join Date
    Jan 2011
    Posts
    18

    Default

    Well, i'm new but i made to set a variable in session with JSP tags

    To set
    Code:
    <core:set var="variableName" value="variable_value" scope="session" />
    To get
    sessionScope.variableName

    Example,

    Code:
    <form:input id="username" name="username" path="" value="${sessionScope.variableName}" />
    But you should use a model to transport data from a view and other, i guess

  4. #4
    Join Date
    Oct 2009
    Location
    Minneapolis, MN
    Posts
    137

    Default

    Quote Originally Posted by Fogel View Post
    Hello, I'm very noob on spring and I'm having some problems passing parameters between controllers

    Here controller 1:

    @RequestMapping(method = RequestMethod.POST)
    public String onSubmit(@ModelAttribute("pedido") Pedido pedido, HttpServletRequest request)
    throws Exception
    {
    String login = (String) request.getSession().getAttribute("username");

    if ( WebUtils.hasSubmitParameter(request, "relatorio") )
    {
    request.setAttribute("pedido", pedido);
    return "redirect:Relatorio.html";
    }

    Controller 2:

    @RequestMapping(method = RequestMethod.GET)
    public String showUserForm (HttpServletRequest request)
    {
    Pedido pedido = (Pedido)request.getAttribute("pedido");


    The variable 'pedido' is always coming null when it shouldnt be. I tryied to use 'forward' instead of 'redirect' and I got this message:

    type Status report

    messageRequest method 'POST' not supported

    descriptionThe specified HTTP method is not allowed for the requested resource (Request method 'POST' not supported).

    Hope someone can help me.
    ps: sorry my english
    Look at your jsp form tag, does it use the same model/command class name as you have in the controller
    (@ModelAttribute("pedido") Pedido pedido
    I guess if you take out this parameter in the post method you can see it will get called. it has problems populating your modelattribute.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •