上来先
骂
两句
卧槽!卧槽!卧槽!
找了俩小时,我哭了
主要检查SpringMVC配置文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!--只扫描controller里面的文件-->
<context:component-scan base-package="com.galaxy">
<!--exclude:排除-->
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
<!--配置视图解析器-->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<!--
<!–过滤静态资源–>
<mvc:resources mapping="/css/**" location="/css/"/>
<mvc:resources mapping="/img/**" location="/img/"/>
<mvc:resources mapping="/js/**" location="/js/"/>
-->
<!--配置SpringMVC注解扫描-->
<mvc:annotation-driven/>
</beans>
运行后,路径正确,显示不出来内容
这个是我遇到的一个错误,大概的意思就是没有映射
13-Apr-2020 22:56:31.841 警告 [http-nio-8081-exec-18] org.springframework.web.servlet.DispatcherServlet.noHandlerFound No mapping for GET /queryAll1
因为我用的是IDEA工具,
有自动生成的代码,没有仔细看。
还有自己的基础差,不理解。
最后终于找到了。
这个是修改后的SpringMVC文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!--只扫描controller里面的文件-->
<context:component-scan base-package="com.galaxy">
<!--exclude:排除-->
<!-- <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>-->
<!--include 包括-->
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<!--配置视图解析器-->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<!--
<!–过滤静态资源–>
<mvc:resources mapping="/css/**" location="/css/"/>
<mvc:resources mapping="/img/**" location="/img/"/>
<mvc:resources mapping="/js/**" location="/js/"/>
-->
<!--配置SpringMVC注解扫描-->
<mvc:annotation-driven/>
</beans>
我把< context:include-filter > include:包括 写成 < context:exclude-filter > exclude:排除
完全写反了,能出来才见鬼了。
修改之后页面就显示出来了
希望能够辅助你解决问题!