请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

http://localhost:8080/o2o/shopadmin/shopoperation 404找不到页面

http://localhost:8080/o2o/shopadmin/shopoperation 404找不到页面
我重新在Tomcat里remove再add o2o这个项目然后就找不到这个页面了。
我检查了一下自己的文件啥的好像也没有什么问题昂,麻烦老师帮忙看一下。

spring-web.xml

<?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
    http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc.xsd">
    <!-- 配置SpringMVC -->
    <!-- 1.开启SpringMVC注解模式 -->
    <mvc:annotation-driven />
  
    <!-- 2.静态资源默认servlet配置 (1)加入对静态资源的处理:js,gif,png (2)允许使用"/"做整体映射 -->
    <mvc:resources mapping="/resources/**" location="/resources/" />
    <mvc:default-servlet-handler />
  
    <!-- 3.定义视图解析器 -->
    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/html/"></property>
        <property name="suffix" value=".html"></property>
    </bean>
    <!-- 文件上传解析器 -->
    <bean id="multipartResolver"
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="defaultEncoding" value="utf-8"></property>
        <!-- 1024 * 1024 * 20 = 20M -->
        <property name="maxUploadSize" value="20971520"></property>
        <property name="maxInMemorySize" value="20971520"></property>
    </bean>
  
    <!-- 4.扫描web相关的bean -->
    <context:component-scan base-package="com.imooc.o2o.web" />
</beans>

ShopAdminController.java

package com.imooc.o2o.web.shopadmin;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping(value="shopadmin",method=(RequestMethod.GET))
public class ShopAdminController {
	@RequestMapping(value = "/shopoperation")
	public String shopOperation() {
		return "shop/shopoperation";
	}
}

web.xml

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                      http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    version="3.1" metadata-complete="true">
    <display-name>Archetype Created Web Application</display-name>
    <welcome-file-list>
        <welcome-file>shopoperation.html</welcome-file>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <servlet>
		<servlet-name>spring-dispatcher</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>classpath:spring/spring-*.xml</param-value>
		</init-param>
	</servlet>
	<servlet-mapping>
		<servlet-name>spring-dispatcher</servlet-name>
		<!-- 默认匹配所有的请求 -->
		<url-pattern>/</url-pattern>
	</servlet-mapping>
</web-app>

文件目录结构
图片描述
但是还是找不到页面
图片描述
访问页面时控制台打印的信息
图片描述

正在回答 回答被采纳积分+3

1回答

翔仔 2019-08-30 00:01:07

同学好,因为环境的问题,直接给出源码也没办法精确帮你定位呢。是说原先能打开的,然后啥都没改,移除了tomcat里的项目再添加就出问题访问不到了对不,这里强调的是原先能打开。如果是这样的话,建议clean tomcat 然后 rebuild一下项目试试。

0 回复 有任何疑惑可以回复我~
  • 提问者 慕九州0400739 #1
    老师我clean tomcat 之后,可以访问到index.jsp但是访问路径是http://localhost:8080/bsp/然后还是访问不到web-inf里的页面
    回复 有任何疑惑可以回复我~ 2019-09-02 15:07:42
  • 提问者 慕九州0400739 #2
    最后发现是tomcat下的server.xml里<Context docBase="o2o" path="/bsp" reloadable="true" source="org.eclipse.jst.jee.server:o2o"/></Host>path是“/bsp”,然后我把bsp改成o2o就可以正常访问了.....但是我完全没有印象有改过昂_(°:з」∠)_
    回复 有任何疑惑可以回复我~ 2019-09-02 15:54:53
  • 翔仔 回复 提问者 慕九州0400739 #3
    也许是eclipse的bug,之前的项目名没有自动变更过来导致的:)
    回复 有任何疑惑可以回复我~ 2019-09-02 23:19:58
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信