在网上http://localhost:8080/o2o-1/superadmin/listarea找不到
来源:2-10 验证Controller
慕粉1010571884
2018-08-29
我的项目名是 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;
}
}
2回答
-
翔仔
2018-08-30
同学此外还可以检查下你本地安装好的maven是否与本地的ecipse相互联通了,可以参照下面的截图去配置
同时去到截图里的maven的repository目录下把jar都清除了,之后重新update maven project启动试试
00 -
翔仔
2018-08-29
同学好,首先可以在tomcat启动后,直接访问localhost:8080看看能否访问tomcat首页,这样才能证明tomcat起来,
其次可以看看你的tomcat是否把项目加入到了tomcat里,没有记得添加;
如果还没解决,可以尝试clean tomcat然后重新启动下;
还是解决不了,请对比我的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-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>
022018-08-30
相似问题