我需要通过 Spring MVC 中的 jquery Ajax 调用来处理 Blob 数据。
我正在开发银行应用程序,我有一个网页,我想在其中发送 ajax 请求以检索所有客户详细信息。但问题是,在我的 Pojo 中,我有 clientImage 的 blob 数据类型,我无法处理。
public class Client {
@Id
@GeneratedValue
private Long clientId;
private String clientTitle;
private int clientAge;
private int clientRetirementAge;
private int clientLifeExpectancy;
private String clientFirstName;
private String clientMiddleName;
private String clientLastName;
private String clientNotes;
private String clientGender;
private String clientDOB;
private String clientJoint;
private String clientEmail;
private String clientPhoneNo;
private String riskTolerance;
private String status; // --- Active or notActive
private String password;
private String partnerAvailibility; // -- Yes or No
private String relationshipWithPartner;
private Blob clientImage;
@Column(name="filename")
private String filename;
@Column(name="content_type")
private String contentType;
// =====Client Attributes Block End=====================//
//getter and setter
....
}//end
and see my ajax request....
$.ajax({
type: "POST",
url: "showClientDetails.html",
data: "clientId=" + clientId,
success: function(response){
//console.log(response);
var title=response.clientTitle,firstName=response.clientFirstName,lastName=response.clientLastName,DOB=response.clientDOB,phone=response.clientPhoneNo,email=response.clientEmail,partnerAvailibility=response.partnerAvailibility;
$("#personal-info-title-label").html(title);
$("#personal-info-firstName-label").html(firstName);
$("#personal-info-lastName-label").html(lastName);
$("#personal-info-dob-label").html(DOB);
$("#personal-info-phone-label").html(mp);
$("#personal-info-email-label").html(email);
},
error: function(e){
alert('Error: ' + e.responseText);
}
});
终于看到我的 Spring Controller .....
@RequestMapping(value="/showClientDetails",method=RequestMethod.POST)
public @ResponseBody Client showClientDetails(HttpServletRequest request,Client client) {
//System.out.println("in show clients");
Long clientId=Long.parseLong(request.getParameter("clientId"));
client=userService.getClientDetails(clientId);
return client;
}
我只需要通过 ajax 请求来处理这个问题。因此,如果您有任何解决方案,请帮助我,或者如果您知道,请为我提供任何链接。