“Error: HttpStatus cannot be resolved to a variabl

2019-04-28 13:59发布

问题:

I am getting error in below code at line 2: @ResponseStatus(HttpStatus.OK). Error is: "HttpStatus cannot be resolved to a variable". What imports are required for this? Am i missing any necessary jar file? Any help?

@RequestMapping( value = "/{id}", method = RequestMethod.GET )
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public String validateUser( @PathVariable( "id" ) String id){

     Return "User Validated"
}

回答1:

Add:

import org.springframework.http.HttpStatus;