在启动类上添加了注解:

@EnableTransactionManagement,

 postMan测试接口,以这种方式传递参数:

【spring】spring boot中使用@EnableTransactionManagement 以后,spring mvc接收前台ajax的post方法传过来的参数,使用@RequestBody接收不到参数

测试结果:

【spring】spring boot中使用@EnableTransactionManagement 以后,spring mvc接收前台ajax的post方法传过来的参数,使用@RequestBody接收不到参数

 接收不到参数

 【spring】spring boot中使用@EnableTransactionManagement 以后,spring mvc接收前台ajax的post方法传过来的参数,使用@RequestBody接收不到参数

 

问题解决:

原因:是因为 这个项目中的Controller层 其实是有一层接口层,一层实现层。

【spring】spring boot中使用@EnableTransactionManagement 以后,spring mvc接收前台ajax的post方法传过来的参数,使用@RequestBody接收不到参数

 

 其实controller层不应该有接口层,而直接就是 实现层。

像上面这种有接口层,又有实现层的设计,会导致在启动类添加了@EnableTransactionManagement注解之后,导致

接口层:

package com.pisen.cloud.luna.ms.goods.api;

import com.pisen.cloud.luna.core.result.AjaxResult;
import com.pisen.cloud.luna.core.result.PageResult;
import com.pisen.cloud.luna.ms.goods.base.domain.GoodsAid;
import com.pisen.cloud.luna.ms.goods.base.domain.GoodsAidLog;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@RequestMapping("/ten/goodsAid")
public interface ITenGoodsAidApi extends ICRUDCommonApi<GoodsAid> {

    /**
     * 售后服务的更新操作
     *
     * 注意地址!!!!!!是 updated
     *
     * 服务未启用-->可以修改商品分类和 服务信息
     * 服务已启用-->不可以修改商品分类  可以修改服务信息
     *
     * @param entity
     * @return
     */
    @RequestMapping(value = "/updated",method = RequestMethod.POST)
    AjaxResult<GoodsAid> updated(GoodsAid entity);

    /**
     * 启用售后辅助服务配置
     *
     * 启用以后不能再禁用或者删除
     *
     * 所以禁用操作不提供
     * @param aid
     * @return
     */
    @RequestMapping(value = "/enable",method = RequestMethod.POST)
    AjaxResult<String> enable(GoodsAid aid);


    /**
     * 分页查询 售后服务日志
     *
     * @param entity
     *            实例对象
     * @return 标准返回对象
     */
    @RequestMapping(value = "/log/pageFind", method = RequestMethod.GET)
    PageResult<GoodsAidLog> pageFind(@RequestBody GoodsAidLog entity) ;


    /**
     * 新增实例 售后服务日志
     *
     * @param entity
     *            实例对象
     * @return 标准返回对象
     */
    @RequestMapping(value = "/log/insert", method = RequestMethod.POST)
    public AjaxResult<GoodsAidLog> insert(@RequestBody GoodsAidLog entity);

}
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-18
  • 2021-06-21
  • 2021-12-21
  • 2022-12-23
猜你喜欢
  • 2021-10-10
  • 2021-10-25
  • 2022-12-23
  • 2021-08-10
  • 2021-08-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案