问题描述
- springMVC中jsp页面访问路径404错误?
-
配置如下
spring-servlet.xml
class="org.springframework.web.servlet.view.InternalResourceViewResolver">Web.xml
spring
*.do我在JSP页面的路径是WebContent/views/EnterpriseInfoManag/pollutionBasInfo.jsp
controller的代码是:
@Controller
public class PollutionBasInfoController {@Resource private PollutionBasInfoService pollutionBasInfoService; @RequestMapping("/findPollutionBasInfo.do") public @ResponseBody List<TBasEnterprise> findPollutionBasInfo(){ List<TBasEnterprise> list = pollutionBasInfoService.findPollutionBasInfo(); return list; }
我用JS访问controller: url:'findPollutionBasInfo.do'
但是地址就自动变成 http://localhost:8080/SKPWMS/views/EnterpriseInfoManag/findPollutionBasInfo.do
,访问controller的路径自动在前面加上了/views/EnterpriseInfoManag,导致404错误,求指导,为什么会这样,应该怎样解决啊???
解决方案
404错误1000000%是自己代码的问题
解决方案二:
楼主一定是忘了在spring-mvc.xml指定jsp页面的相对路径了,别忘了指定prefix哇
property name="prefix" value="/WEB-INF/pages/"
时间: 2024-12-11 11:48:25