springmvc,通过后台跳转到页面后,页面里面请求的图片资源路径根本不对
有2个内容一模一样的页面,就是页面路径不一样。一个是在page文件夹,一个直接放在webRoot下。

webRoot下的页面
page下的页面
我在后台,用注解的方式,控制请求转发到的页面,有2个方法
method1通过http://localhost:8080/springMvc1/method1跳转到page/welcome.jsp
图片路径根本不对,少了springMvc1

method2通过http://localhost:8080/springMvc1/test/method2跳转到welcome.jsp
图片路径也不对,多了个test

我就搞晕了,这设置请求的路径,以及设置返回路径,怎么影响了页面资源的路径,求大神点拨一下

webRoot下的页面
<body>
页面目录:WebContent下<br/>
本次跳转使用方法${method }<br/>
picture:<img src="image/a.jpg" alt="picture" />
</body>
</html>page下的页面
<body>
页面目录:WebContent/page下<br/>
本次跳转使用方法${method }<br/>
picture:<img src="../image/a.jpg" alt="picture" />
</body>我在后台,用注解的方式,控制请求转发到的页面,有2个方法
package com.sudy.controller.annotation;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
@Controller
public class AnnotationController extends MultiActionController{
@RequestMapping(value="/method1",method=RequestMethod.GET)
public ModelAndView method1(HttpServletRequest arg0,
HttpServletResponse arg1) throws Exception {
return new ModelAndView("/page/welcome","method","method1");
}
@RequestMapping(value="/test/method2",method=RequestMethod.GET)
public ModelAndView method2(HttpServletRequest arg0,
HttpServletResponse arg1) throws Exception {
return new ModelAndView("/welcome","method","method2");
}
}
method1通过http://localhost:8080/springMvc1/method1跳转到page/welcome.jsp
图片路径根本不对,少了springMvc1

method2通过http://localhost:8080/springMvc1/test/method2跳转到welcome.jsp
图片路径也不对,多了个test

我就搞晕了,这设置请求的路径,以及设置返回路径,怎么影响了页面资源的路径,求大神点拨一下
...全文
相关推荐
springMVC几种页面跳转方式小结
本文档详细介绍了Spring MVC框架中实现页面跳转的几种常见方法,特别关注于注解方式下的处理。首先,我们回顾了控制器(Controller)的基本配置,包括使用@Controller注解来定义一个
springMVC使用注解方式进行页面跳转
#### 二、使用注解进行页面跳转的关键概念1. **@Controller**:该注解用于标记一个类作为Spring MVC的控制器。控制器类通常负责处理用户请求,并返回适当的模型和视图。2.
SpringMVC实现前端后台交互传递数据
SpringMVC实现前端后台交互传递数据本篇文章主要介绍了SpringMVC实现前端后台传递数据的方法,其中包括使用Controller接收和传递数据的多种方式,以及配置SpringMVC的基本步骤
Spring MVC点击链接,跳转到指定页面
在给定的场景中,我们有一个简单的应用,用户在`index.jsp`页面上点击一个链接,目标是跳转到`success.jsp`页面。这涉及到Spring MVC的请求处理流程和视图解析。1.
springMvc请求的跳转和传值的方法
### Forward 跳转`forward`跳转是在服务器端内部完成的,浏览器并不感知这个过程,它只是显示最终呈现的页面。以下是使用`forward`进行页面跳转的几种方法:1.


Web 开发
