在我部署在tomcat上的项目中,有两场战争。我必须在UI操作上将请求从一个war重定向到另一个war。它目前是基于Spring架构的。因此,我在第一次战争中添加了这段代码,以将请求重定向到另一个war,但无法重定向。
@Controller
@RequestMapping(value = "/monetize")
public class MyFirstWarController {
private static final Logger logger = LoggerFactory.getLogger(MyFirstWarController.class);
@Autowired
private ServletContext servletContext;
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
public String showConsumerInterests(HttpServletRequest request, Model model) {
//WebApplicationContextUtils.getRequiredWebApplicationContext(request.getSession().getServletContext());
logger.info("In the First War Servlet Context");
servletContext = servletContext.getContext("/monetize");
return "monetize/dashboard";
}
} 我试图接触到我的第二次战争的控制器,在那里,我已经为请求http://MyLocalHost:8080/monetize/dashboard提供了MVC控制器,与上面类似的控制器。我在ViewResolver中有什么需要提供的吗?我在网上找不到任何解决办法。
发布于 2014-08-26 18:20:34
在这种情况下,您应该将redirect:前缀添加到控制器的返回值中。
例如:
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
public String showConsumerInterests(HttpServletRequest request, Model model) {
//any logic
return "redirect:http://localhost:8080/monetize/dashboard";
}也可以检查this。
https://stackoverflow.com/questions/25512376
复制相似问题