Finally, using AJAX to commit successfully, here are some code, if there is time to refine.
Ajax:
function Test () {
$.ajax ({
Type: "POST",
URL: "Test2",
ContentType: "Application/json",
Data: ' {' proptest ': ' Test ', ' list ': [{' Prop1 ': ' A '},{' Prop1 ': ' B '}]} ',
DataType: "JSON",
Success:function (data) {
Console.log (data);
}
});
}
Controller
@ResponseBody
@RequestMapping (value= "/test2", Method=requestmethod.post)
Public String Hello2 (@RequestBody testlist test) {
SYSTEM.OUT.PRINTLN (test);
Value= "/hello/{id}",
@PathVariable (value= "id") Integer ID,
@RequestParam (value= "username") String username
@CookieValue
Return Testbiz.gettest (1L);
}
Spring Configuration:
<bean id= "Mappingjacksonhttpmessageconverter"
class= "Org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" >
<property name= "Supportedmediatypes" >
<list>
<value>text/html;charset=UTF-8</value>
<value>application/json;charset=UTF-8</value>
</list>
</property>
</bean>
Bean Information:
Public class Testlist {
private String proptest;
public String getproptest () {
return proptest;
}
public void Setproptest (String proptest) {
this.proptest = proptest;
}
private list<testinner> List;
public list<testinner> getList () {
return List;
}
public void setlist (list<testinner> List) {
this.list = list;
}
}
public class Testinner {
Private String Prop1;
Public String GetProp1 () {
return PROP1;
}
public void SetProp1 (String prop1) {
THIS.PROP1 = Prop1;
}
}
SPRINGMVC a list within the pass parameter