请稍等 ...
×

采纳答案成功!

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

在网上http://localhost:8080/o2o-1/superadmin/listarea找不到

我的项目名是  o2o-1  Tomcat可以正常启动,

public class AreaController {这个类是正确的,

package com.imooc.o2o.web.superadmin;


import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;

import org.springframework.web.bind.annotation.ResponseBody;


import com.imooc.o2o.entity.Area;

import com.imooc.o2o.service.AreaService;


@Controller

@RequestMapping("/superadmin")

public class AreaController {

@Autowired

private AreaService areaService;

@RequestMapping(value = "/listarea", method = RequestMethod.GET)

@ResponseBody

private Map<String, Object> listArea() {

Map<String, Object> modelMap = new HashMap<String, Object>();

List<Area> list = new ArrayList<Area>();

try {

list = areaService.getAreaList();

modelMap.put("rows", list);

modelMap.put("total", list.size());

} catch (Exception e) {

e.printStackTrace();

modelMap.put("success", false);

modelMap.put("errMsg", e.toString());

}

return modelMap;

}


}


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

插入代码

2回答

翔仔 2018-08-30 13:00:03

同学此外还可以检查下你本地安装好的maven是否与本地的ecipse相互联通了,可以参照下面的截图去配置

https://img1.sycdn.imooc.com//szimg/5b8779b60001989014041066.jpg

同时去到截图里的maven的repository目录下把jar都清除了,之后重新update maven project启动试试

0 回复 有任何疑惑可以回复我~
翔仔 2018-08-29 23:12:52

同学好,首先可以在tomcat启动后,直接访问localhost:8080看看能否访问tomcat首页,这样才能证明tomcat起来,

其次可以看看你的tomcat是否把项目加入到了tomcat里,没有记得添加;

如果还没解决,可以尝试clean tomcat然后重新启动下;

还是解决不了,请对比我的spring-web.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?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-3.2.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>


0 回复 有任何疑惑可以回复我~
  • 提问者 慕粉1010571884 #1
    http://localhost:8080/o2o-1   在网页上可以正常显示。
    http://localhost:8080/o2o-1/superadmin/listarea   HTTP Status 404 – Not Found
    Tomcat  console
    八月 30, 2018 10:25:34 上午 org.springframework.web.servlet.PageNotFound noHandlerFound
    警告: No mapping found for HTTP request with URI [/o2o-1/superadmin/listarea] in DispatcherServlet with name 'spring-dispatcher'
    回复 有任何疑惑可以回复我~ 2018-08-30 10:28:24
  • 翔仔 回复 提问者 慕粉1010571884 #2
    同学有没有按照上面的步骤去排查呢,程序说1是1 不可能大家可以同学这边不可以,肯定还是哪里配置得有问题,404就是找不到对应的路径。
    回复 有任何疑惑可以回复我~ 2018-08-30 12:58:54
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号