spring boot : Send http response code

Add packages

import javax.servlet.http.HttpServletRequest; //optional
import javax.servlet.http.HttpServletResponse;

Add status with response

	@RequestMapping(value = "/{customerId}", method = RequestMethod.GET)
	public void getMydata(@PathVariable("customerId") int customerId, HttpServletRequest request,
			HttpServletResponse response) throws Exception {

			if (is != null) {
				
				//-----Success part-----
				
				
				
			} else {
				 response.setStatus(HttpServletResponse.SC_NO_CONTENT);
			}

	}

 

Author: bm on June 12, 2017
Category: Spring boot

Your comment:

Your Name

Comment:




Last articles