mercredi 30 septembre 2015

Forwarding request to a new controller

I have this two controller from two separate projects lets name them:

  • project1.controller1
  • project2.controller1

Obviously these are two Spring controllers from different projects.What I want is to make project1.controller1 a gateway all request will be sent here. And will process the request if it will go to project2.controller1 or a new controller.

Some pseudoCode:

@Controller
public class someClassFromProject1{

   @RequestMapping(value="/controller1", method=RequestMethod.POST)
   public String smsCatcher(String target, HttpServletRequest request,
        HttpServletResponse response){
           //some processing, converting request to string, etc
           if("someStringThatIsPartOfTheRequest".equals("someString"))
            //carry request and forward it to project2.controller1
           else
            //go to another external controller
         }

    }

And in project2.controller 1 will look something like this:

@Controller
public class someClassFromProject2{

   @RequestMapping(value="/controller1", method=RequestMethod.POST)
   public String smsCatcher(String target, HttpServletRequest request,
        HttpServletResponse response){
          //processing
   }
  }

I've already tried return "forward:/someUrl"; and return "redirect:someUrl";. It didn't work and it didn't reach project2.controller1. So any ideas on this one?

Edit: Forgot to add this one, different project means different war but deployed on the same sever

Thanks!




Aucun commentaire:

Enregistrer un commentaire