蔡香满屋
站在牛顿头上吃苹果

@PathVariable作用重要解释:

@PathVariable 获取的是请求路径中参数的值 @RequestParam 获取的是请求参数,一般是url问号后面的参数值

@Param作用:

@param是参数的解释

工作实际应用场景:

在controller层使用PathVariable 接收前端在url路径中传进来的参数processInstanceId:

前端代码:

 query(processInstanceQueryApi.detail + '/' + processInstanceId).then(response => {}

 后端controller层代码:

public WebResponse<List<ProcessInstanceDTO>> get(@PathVariable String processInstanceId) {} 

后端service实现层:

@Override
	public List<ProcessInstanceDTO> processInstanceDetail(String processInstanceId) {
		return processInstanceQueryMapper.processInstanceDetail(processInstanceId);
	}

后端在mapper.java即相当于dao接口层需要使用@Param对参数做出解释:

public List<ProcessInstanceDTO> processInstanceDetail(@Param("processInstanceId") String processInstanceId);

  这样处理之后才可以将String processInstanceId这个字符串注入到mybatis的xml中sql中执行

<select id="processInstanceDetail" parameterType="java.lang.String" resultMap="AuditNodeBaseResultMap">
select * from dual
where id = #{processId,jdbcType=VARCHAR}
</select>

  

 

posted on 2018-10-30 11:50  蔡香满屋  阅读(369)  评论(0)    收藏  举报