- edit-- 发生的事情是我可以看到控制台/ sout项目,我从数据库中获取对象,当前我得到500内部服务器错误,每个修复我尝试了一个错误消失(400已经很受欢迎)和然后我得到另一个,我解决它,然后我得到另一个。
我正在获取数据,但是通话仍然失败,我无法对信息做任何事情,我看到了这些数据,但我无法弄清楚如何正确捕获它。
我想要做的是搜索客户,如果该客户存在则在下一页表单中填充该信息,如果不是仅将搜索条件插入下一页表单中的相应字段。
这是javascript,我无法弄清楚加载函数,因为它似乎没有正常工作(不确定如何正确捕获数据)。
$('#search-customer').click(function (event) {
var testdata = document.getElementById('searchCustomerForm');
// var isvalid = checkForm(form);
// if (isvalid === false) {
// event.preventDefault();
// alert('is valid===false');
// } else {
alert('hit search customer ajaxcall');
$.ajax({
type: 'GET',
url: 'customerLookup/?firstName=' + $('#search_first_Name').val() + '&lastName=' + $('#search_last_Name').val() + '&compId=' + companyId,
data: JSON.stringify({
firstName: $('#search-first_name').val(),
lastName: $('#search-last_name').val(),
// dob: $('#search_birthdate').val(),
// license: $('#search_license_number').val()
// dob: $('#search_birthdate').val(),
compId: $('#search_companyId').val(companyId)
}),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
'dataType': 'json'
}).done(function (data, status) {
if (data !== null) {
window.location = "/app/ticketStepOneTwoAddCustomer";
loadCustomerInputForm(data, status);
alert('customer found, moving to confirm');
}
else if (data === null) {
window.location = "/app/ticketStepOneTwoAddCustomer";
addSearchInfoToInputCustomerForm();
alert('no customer of that name found, moving to add customer');
}
}).fail(function () {
alert('not a success');
// window.location = "/app/ticketStepOneTwoAddCustomer";
});
});
function loadinputcustomerform(data, status) {
alert('hit loadinputcustomerform function');
console.log(cust.customer.getCustomerFirstName());
console.log(data.customer.getCustomerMiddleName());
console.log(customer.getCustomerLastName());
这是控制器
@RequestMapping(value = {"/customerLookup"}, method = RequestMethod.GET)
@ResponseBody
public Customer getCustomerByCriteria(
@RequestParam(value = "compId", required = false) int compId,
@RequestParam(value = "firstName", required = false) String fName,
@RequestParam(value = "lastName", required = false) String lName) {
System.out.println("here: " + compId + " -- " + fName);
Customer cust = customerService.searchCustomer(fName, lName, compId);
//System.out.println(cust.getCustomerLicense());
return cust;
}
在java方面,客户只是一个对象,在DB中,companyID是FK,一切都需要compID,我在想他们应该制作一个客户的hashmap或list但不是我的区域,这就是我所拥有的与...合作。
这是html
<form id="inputCustomerForm">
<div class="form-group">
<label for="firstName">First Name</label>
<input type="text" class="form-control" id="input_first_Name" style="text-transform:uppercase;" onkeyup="this.value = this.value.toUpperCase()" placeholder="First Name">
</div>
<div class="form-group">
<label for="middleName">Middle Name</label>
<input type="text" class="form-control" id="input_middle_Name" style="text-transform:uppercase;" onkeyup="this.value = this.value.toUpperCase()" placeholder="Middle Name">
</div>
<div class="form-group">
<label for="lastName">Last Name</label>
<input type="text" class="form-control" id="input_last_Name" style="text-transform:uppercase;" onkeyup="this.value = this.value.toUpperCase()" placeholder="Last Name">
</div>
<div class="form-group">
<label for="dob">D.O.B. YYYYMMDD</label>
<input type="text" class="form-control" id="input_birthdate" style="text-transform:uppercase;" onkeyup="this.value = this.value.toUpperCase()" placeholder="YYYYMMDD">
</div>
<div class="form-group">
<label for="addressone">Address</label>
<input type="text" class="form-control" id="input_addressone" style="text-transform:uppercase;" onkeyup="this.value = this.value.toUpperCase()" placeholder="123 street">
</div>
<div class="form-group">
<label for="addresstwo">Address</label>
<input type="text" class="form-control" id="input_addresstwo" style="text-transform:uppercase;" onkeyup="this.value = this.value.toUpperCase()" placeholder="po 1111">
</div>
<div class="form-group">
<label for="city">City</label>
<input type="text" class="form-control" id="input_city" style="text-transform:uppercase;" onkeyup="this.value = this.value.toUpperCase()" placeholder="Columbus">
</div>
<div class="form-group">
<label for="state">State</label>
<input type="text" class="form-control" id="input_state" style="text-transform:uppercase;" onkeyup="this.value = this.value.toUpperCase()" placeholder="OH">
</div>
<div class="form-group">
<label for="zip">ZipCode</label>
<input type="text" class="form-control" id="input_zip" style="text-transform:uppercase;" onkeyup="this.value = this.value.toUpperCase()" placeholder="43026">
</div>
<div class="form-group">
<label for="licenseNumber">License Number</label>
<input type="text" class="form-control" id="input_license_number" style="text-transform:uppercase;" onkeyup="this.value = this.value.toUpperCase()" placeholder="License Number">
</div>
<div class="form-group">
<label for="licenseInputFile">File input</label>
<input type="file" id="licensePhoto">
<p class="help-block">License Photo</p>
</div>
<div class="form-group">
<label for="customerPhotoInputFile">File input</label>
<input type="file" id="customerPhoto">
<p class="help-block">Customer Photo</p>
</div>
<div class="checkbox">
<label>
<input type="checkbox"> Check me out
</label>
</div>
<button type="reset" class="btn btn-default">Clear</button>
<button type="submit" id="input-customer" class="btn btn-default" >Submit</button>
</form>
这是回复
HTTP Status 500 - Could not write JSON: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: com.REMOVED.DTO.Customer["company"]->com.REMOVED.DTO.Company_$$_jvstf68_6["handler"]); nested exception is org.codehaus.jackson.map.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: com.REMOVED.DTO.Customer["company"]->com.REMOVED.DTO.Company_$$_jvstf68_6["handler"])
type Exception report
message Could not write JSON: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: com.REMOVED.DTO.Customer["company"]->com.REMOVED.DTO.Company_$$_jvstf68_6["handler"]); nested exception is org.codehaus.jackson.map.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: com.REMOVED.DTO.Customer["company"]->com.REMOVED.DTO.Company_$$_jvstf68_6["handler"])
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: com.REMOVED.DTO.Customer["company"]->com.REMOVED.DTO.Company_$$_jvstf68_6["handler"]); nested exception is org.codehaus.jackson.map.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: com.REMOVED.DTO.Customer["company"]->com.REMOVED.DTO.Company_$$_jvstf68_6["handler"])
org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.writeInternal(MappingJacksonHttpMessageConverter.java:212)
org.springframework.http.converter.AbstractHttpMessageConverter.write(AbstractHttpMessageConverter.java:207)
org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:148)
org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:90)
org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor.java:193)
org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:71)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:122)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
root cause
org.codehaus.jackson.map.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: com.REMOVED.DTO.Customer["company"]->com.REMOVED.DTO.Company_$$_jvstf68_6["handler"])
org.codehaus.jackson.map.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:52)
org.codehaus.jackson.map.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:25)
org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446)
org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150)
org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112)
org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446)
org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150)
org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112)
org.codehaus.jackson.map.ser.StdSerializerProvider._serializeValue(StdSerializerProvider.java:610)
org.codehaus.jackson.map.ser.StdSerializerProvider.serializeValue(StdSerializerProvider.java:256)
org.codehaus.jackson.map.ObjectMapper.writeValue(ObjectMapper.java:1613)
org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.writeInternal(MappingJacksonHttpMessageConverter.java:209)
org.springframework.http.converter.AbstractHttpMessageConverter.write(AbstractHttpMessageConverter.java:207)
org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:148)
org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:90)
org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor.java:193)
org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:71)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:122)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.15 logs.
我当时认为私有客户属性是一个问题,但我认为公共吸气者和制定者仍然可以使用。