zoukankan      html  css  js  c++  java
  • Spring MVC

    1. spring mvc如果return是ok客户端就一直转呀转的,都是拿不到response,如果换成其实字符串就可以,奇怪。

        @RequestMapping(value = "test", produces="application/json;charset=utf-8") 
        @ResponseBody
        public String test(){
            return "ok";
        }

    2. @Resource和@Autowired的区别。

    比如:

        @Autowired
        private RecommendCommonService recommendService;

    这个会去查找RecommendCommonService类型的bean,找不到就报UnsatisfiedDependencyException和NoUniqueBeanDefinitionException错误。

    如果是

        @Resource
        private RecommendCommonService recommendService;

    就会先去查找有没有id为recommendService的bean,如果没有,就去找有没有类型为RecommendCommonService 的bean.

    2017-10-10

    对Strping的注入规则有认识上的错误。我今天在一个@Service的类SystemSettingsService的构造函数里,想调用它的一个成员接口

        @Autowired
        private CommonService commonService;

    发现,在构造函数调用的时候commonService是空的,但是,把SystemSettingsService放到控制器,或者别的Service类里面作为成员接口的时候,再调用它的一个方法,发现这时候,

    commonService不为空。

    2018-03-19

    如果路径定义(请求接口)重了,会报这个错。

    2018-03-19 14:56:14,168 WARN  support.XmlWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: 
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name
    'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping': Invocation of init method failed; nested exception is
    java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'gameHallController' method public void com.feikantec.game.suit_tiles.controller.GameHallController.desk(javax.servlet.http.HttpServletResponse,java.lang.Integer,java.lang.Integer) to {[/hallStat]}: There is already 'debugController' bean method public void com.feikantec.game.suit_tiles.controller.DebugController.hallStat(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) mapped.
  • 相关阅读:
    canvas上的像素操作(图像复制,细调)
    AMD、CMD、CommonJS 和 ES6 模块化规范
    JS垃圾回收
    函数式编程中如何处理副作用?
    vue中的$on,$emit,$once,$off源码实现
    重新学习react生命周期
    keep alive实现原理
    读取 url 参数方法
    使用Bootstratp Blazor +EF Codefirst 愉快的增删改查!
    记录一下爬取微信小程序视频的过程!
  • 原文地址:https://www.cnblogs.com/angelshelter/p/6600998.html
Copyright © 2011-2022 走看看