Re: [問題] Spring MVC 跳脫 "," to array

作者: k80097   2014-10-31 00:20:06
※ 引述《k80097 ()》之銘言:
: 大家好
: 想請問在spring mvc裡
: Form summit input text
: 如何跳脫","符號而不會轉換成 array 呢?
: 謝謝
controller:
@RequestMapping(value = "/test")
public String test(@ModelAttribute TestObject o){
}
public class TestObject {
private Test[] tests;
//getter tests
//setter tests
}
public class Test {
private String[] stringArray;
//getter stringArray
//setter stringArray
}
JSP:
<input type="text" name="tests[0].stringArray" />
輸入值為: a,b,c
controller 接到就直接轉array了
作者: ssccg (23)   2014-10-31 06:17:00
tests[0].stringArray[0] ?
作者: cyclone350 (老子我最神)   2014-10-31 09:13:00
樓上方法測試: 對Array無效,對List有效
作者: yyc1217 (somo)   2014-10-31 09:23:00
name直接用tests[]然後controller這邊就String[] tests

Links booklink

Contact Us: admin [ a t ] ucptt.com