SpringMVC 下的项目 出现404错误!控制台没有报错 !该如何解决 !

csdn17668 2017-03-22 11:21:42
404错误


控制台 不报错


servlet-context.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">

<annotation-driven />
<resources mapping="/resources/**" location="/resources/" />
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/src/main/webapp/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>

<beans:bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<beans:property name="basename" value="classpath:message" />
<beans:property name="defaultEncoding" value="UTF-8" />
</beans:bean>

<context:component-scan base-package="com.onlinebanking.controllers" />

</beans:beans>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<!-- Spring Security Configuration File -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/spring-security.xml</param-value>
</context-param>

<!-- Creates the Spring Container shared by all Servlet and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
</listener>

<session-config>
<session-timeout>10</session-timeout>
</session-config>

<!-- Spring Security Filter -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<!-- Spring MVC - START -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/appServlet/servlet-context.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!-- Spring MVC - END -->
</web-app>
...全文
752 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
大扑棱蛾子 2017-03-29
  • 打赏
  • 举报
回复
3、如果你用了shiro或者spring security控制权限,登录成功的地址应写成`/`,不能写成项目名
大扑棱蛾子 2017-03-29
  • 打赏
  • 举报
回复
应该是页面的路径有问题, 1、检查页面是否有base标签 2、如果没有base标签应该在路径前加上basepath(basepath可以从request中组装出来) 举个栗子,你的项目名是project那你的basepath就是`/project/`,如果你的项目没有项目名,那basepath就是`/`
作现 2017-03-28
  • 打赏
  • 举报
回复
是你页面中的 请求路径有问题
jins_ 2017-03-28
  • 打赏
  • 举报
回复
把你的Controller类也贴出来,
podd 2017-03-28
  • 打赏
  • 举报
回复
引用 12 楼 yxk17668 的回复:
这个是报错信息 WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/PitchForkBanking/PitchForkBanking/] in DispatcherServlet with name 'appServlet' WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/PitchForkBanking/PitchForkBanking/login.do] in DispatcherServlet with name 'appServlet' @lrx2011 难道是我控制器出错吗?第一次用的springmvc
你请求的路径错误
csdn17668 2017-03-28
  • 打赏
  • 举报
回复
这个是报错信息 WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/PitchForkBanking/PitchForkBanking/] in DispatcherServlet with name 'appServlet' WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/PitchForkBanking/PitchForkBanking/login.do] in DispatcherServlet with name 'appServlet' @lrx2011 难道是我控制器出错吗?第一次用的springmvc
podd 2017-03-28
  • 打赏
  • 举报
回复
引用 10 楼 yxk17668 的回复:
引用
#9
好的,我试一下,谢谢
重复试下 ${pageContext.request.contextPath}/ar/br/login.do
csdn17668 2017-03-28
  • 打赏
  • 举报
回复
引用
#9
好的,我试一下,谢谢
podd 2017-03-28
  • 打赏
  • 举报
回复
引用 8 楼 yxk17668 的回复:
@lrx2011
自己慢慢想下,很容易解决的
csdn17668 2017-03-28
  • 打赏
  • 举报
回复
@lrx2011
podd 2017-03-28
  • 打赏
  • 举报
回复
引用 6 楼 yxk17668 的回复:
请看我的URI为什么会出现两个"/projectname"呢?是配置文件的问题吗?
从你底层配的路径,controller里写的路径去看
csdn17668 2017-03-28
  • 打赏
  • 举报
回复
请看我的URI为什么会出现两个"/projectname"呢?是配置文件的问题吗?
podd 2017-03-28
  • 打赏
  • 举报
回复

@Controller
@RequestMapping("/em")
public class EmergencyMeasureController {
 
    @RequestMapping("/delete")
    @ResponseBody
    public int delete(Integer id) throws Exception {
        return 1;
    }

url:  /em/delete.do
}
podd 2017-03-28
  • 打赏
  • 举报
回复
你后面还要加上.do
csdn17668 2017-03-28
  • 打赏
  • 举报
回复
@jaune161 博主能看一下这是什么问题嘛?还有为什么我的URI会出现两个项目名呢?
演员_ 2017-03-22
  • 打赏
  • 举报
回复
看你地址有没有错,这又一个博客你可以看一下http://blog.csdn.net/yangkai_hudong/article/details/8133220

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧