Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
Cómo usar la redirección en ModelAndView

Quiero redirigir mi URL a http://localhost:8080/ClickBuy/product/details a http://localhost:8080/ClickBuy/home .

Tengo Define header.jsp y lo incluyo en todas mis páginas. Cuando hago clic en el enlace de inicio desde cualquier otro lugar, agrego /home desde la URL actual. Entonces, muestra el error 404.

Controlador

 public ModelAndView allProduct() { ModelAndView model=new ModelAndView("pl"); model.addObject("data", pd.getAllProducts()); return model; }

¿Cómo puedo usar redirect:/ en el método de tipo de retorno ModelAndView?

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Para usar redirección:/ en el método de tipo de devolución ModelAndView, intente seguir

 ModelAndView modelAndView = new ModelAndView("redirect:/abc.htm"); modelAndView.addObject("modelAttribute" , new ModelAttribute()); return modelAndView;

También puede regresar a la página de inicio usando el tipo de retorno de cadena si no necesita ningún modelo en la página de inicio

 @RequestMapping(value = "/home.htm", method = RequestMethod.GET) public String homePage() { return "home"; }
about 4 years ago · Santiago Trujillo Report

0

Hay diferentes formas de redirigir, pero usar Spring ModelView Object es simple

 @RequestMapping(value = "/redirecturl", method = RequestMethod.POST) public ModelAndView methodPost() { return new ModelAndView( "redirect:/login.html"); }
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!