出现这个错误 :严重Servlet.service() for servlet [springMVC] in context with path [/ssm] threw exception

 

 

总结原因如下: 1 目录webapp下没有web.xml文件            

                        2 在serviceImpl层 或者 Controller层注解没写对或者没有写           

                        3 导错包

                        4 比如 在Maven项目中 有一个拦截器(jar项目)  在另一个项目中要使用这个拦截器并且在(war)springmvc.xml 中也配置了拦截器,此时报错,原因是你没有把拦截器(jar项目)依赖进来,就像你说了有这个东西 没有说东西在哪

                       5 maven中被依赖的项目没有启动 比如A依赖B ,但是启动的时候你启动了A后启动了B ,会出现找不到依赖

<!-- 配置拦截器 -->
	       	<mvc:interceptors>
	       		<mvc:interceptor>
	       			<!-- 需要拦截器的请求路径 -->
	       			<mvc:mapping path="/**"/>
	       			<!-- 实例化拦截器对象 -->
					<bean class="com.e.ego.interceptor.UserInterceptor"></bean>
	       		</mvc:interceptor>
	       	
	       	</mvc:interceptors>

 

 

 

下图是:没有写@Autowired注解 和 没有web.xml

 

ServiceImpl层:

import java.util.List;

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

import com.e.ego.manager.service.ManagerItemCatService;
import com.e.ego.rpc.service.TbItemCatService;
import com.e.entity.Tree;

@Service
public class MnaagerItemCatServiceImpl implements ManagerItemCatService {
 
	//注入远程代理对象
	@Autowired
	private TbItemCatService tbItemCatServiceProxy;

	public List<Tree> loadManagerItemCatListService(Long id) {

		
		return tbItemCatServiceProxy.loadTbItemCatListService(id);
	}

}

Controller 层:

import java.util.List;

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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.e.ego.manager.service.ManagerItemCatService;
import com.e.entity.Tree;

@Controller
public class ManagerItemCatController {

	@Autowired
	private ManagerItemCatService managerItemCatService;
	
	@RequestMapping("/item/cat/list")
	@ResponseBody
	public List<Tree> itemCatList(@RequestParam(defaultValue="0")Long id){
		return managerItemCatService.loadManagerItemCatListService(id);
	}

}

                                                

  • 5
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值