Giter Site home page Giter Site logo

jsondemo's People

Contributors

pzwm avatar qm1995 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jsondemo's Issues

为什么将map转换标记为弃用

/**

  • map转换器

  • @author: qiumin
    **/
    @deprecated
    public class MapConverter implements Converter{

    /**

    • 只支持json转map
    • @param clazz
    • @param value
    • @return
      */
      @OverRide
      public Object convert(Type clazz, Object value) {
      if (clazz == null){
      throw new RuntimeException("type must be not null");
      }else if (value == null){
      return null;
      }else if (value instanceof String && "".equals(String.valueOf(value))){
      return null;
      }
      Gson gson = new Gson();
      return gson.fromJson(String.valueOf(value),clazz);
      }

    @OverRide
    public boolean support(Class<?> clazz) {
    return ConverterUtil.isMapType(clazz);
    }
    }
    没有新的方法能够代替,是因为有什么问题吗

@EnableWebMvc 导致SpringBoot中 WebMvc的自动配置失效。

去掉@EnableWebMvc

@Autowired
private RequestMappingHandlerAdapter requestMappingHandlerAdapter;
@Autowired
private RequestJsonHandler requestJsonHandler;

@PostConstruct
public void init() {
    // 获取内建的resolvers
    List<HandlerMethodArgumentResolver> buildInList = requestMappingHandlerAdapter.getArgumentResolvers();
    // 重建resolvers
    List<HandlerMethodArgumentResolver> newResolvers = new ArrayList<>(buildInList.size() + 1);
    // 自定义的放到第一位
    newResolvers.add(requestJsonHandler);
    // 再放内建的
    newResolvers.addAll(buildInList);
    // 重设resolvers
    requestMappingHandlerAdapter.setArgumentResolvers(newResolvers);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.