1.加入jersey的jar包,包括api,ex,lib
2.在web.xml中增加配置:
3.新建java文件:
@Path( "/updateLocationService")
public class UpdateLocationService {
@Autowired
ManageditemManagerAO itemAO;
@Autowired
UserManagerAO userAO;
@GET
@Produces(MediaType.TEXT_PLAIN)
public String updateLocation( @QueryParam( "equipment_id") String eqId, @QueryParam( "location") String location,
@QueryParam( "user") String user, @QueryParam( "password") String password) {
if ( location == null || location.length() == 0) {
return "Error:location is empty";
}
if ( eqId == null || eqId.length() == 0) {
return "Error:equipment_id is empty";
}
if (LdapHelper. verifyAccountAndPwd(user, password) == false) {
return "Error:user/password not correct,please use your compute login user&password";
}
StorageManagementManageditemExt item = itemAO.getItemByEquipmentId( eqId);
if( item == null){
return "Error:Can't find item by equipment_id:" +eqId ;
}
item.setLocation( location);
itemAO.updateItem( item, userAO.getUserByUserName( user).getId());
return "Success!";
}
}
4.在浏览器中输入url:http://localhost:8880/nams/rest/updateLocationService/就会自动调用
https://blog.csdn.net/weixin_33912453/article/details/91890915