Jsp向action传list set或map
List Java代码 1 package com.sh.pojo; 2 3 import java.util.Date; 4 5 publicclass Register { 6 private String name; 7 private String pwd; 8 privateint age; 9 private Date birthday; 10 private String address; 11 12 //get set 13 }
Java代码 14 package com.sh.action; 15 16 import java.util.ArrayList; 17 import java.util.List; 18 19 import com.opensymphony.xwork2.ActionSupport; 20 import com.sh.pojo.Register; 21 22 publicclass RegisterAction extends ActionSupport { 23 24 privatestaticfinallong serialVersionUID = 1L; 25 private List 26 public List 27 return registers; 28 } 29 publicvoid setRegisters(List 30 this.registers = registers; 31 } 32 public String execute() throws Exception { 33 return SUCCESS; 34 } 35 36 }
Java代码 37 Element_registers=com.sh.pojo.Register 38 CreateIfNull_sysConfigs = true //Element_是固定的后面接action中的list集合变量名,后面是泛型中的对象类。
Xml代码 39 40 41 "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" 42 "http://struts.apache.org/dtds/struts-2.3.dtd"> 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
Html代码 68 69 70
71 72 73 74 75 76 77 78 79 80
81 84 87 90 93 96 97 98 99 100
Html代码 101 102
103 104 105 106 107 108 109 110 111
112 115 118 121 124 127 128 129 130
Html代码 131 132 163
Java代码 164 package com.sh.action; 165 166 import java.util.LinkedHashSet; 167 import java.util.Set; 168 169 import com.opensymphony.xwork2.ActionSupport; 170 import com.sh.pojo.Register; 171 172 publicclass RegisterSetAction extends ActionSupport { 173 174 private Set 175 176 public Set 177 return registers; 178 } 179 180 publicvoid setRegisters(Set 181 this.registers = registers; 182 } 183 184 @Override 185 public String execute() throws Exception { 186 // TODO Auto-generated method stub 187 return SUCCESS; 188 } 189 190 }
Java代码 191 KeyProperty_registers=name //KeyProperty 如果是取 单个 就需要这个 192 Element_registers=com.sh.pojo.Register
Html代码 193 194 195
196 197 198 199 200 201 202 203 204 205
206 209 212 215 218 221 222 223 224 225
Html代码 226 227
228 229 230 231 232 233 234 235 ===========遍历所有的=========
236 237
238 241 244 247 250 253 254 255 256 ===========单独去其中的一个(知道其中的key wei admin)========
257
258 261 264 267 270 273 274
Java代码 275 package com.sh.action; 276 277 import java.util.HashMap; 278 import java.util.Map; 279 280 import com.opensymphony.xwork2.ActionSupport; 281 import com.sh.pojo.Register; 282 283 publicclass RegisterHashMapAction extends ActionSupport { 284 285 private Map 286 287 public Map 288 return maps; 289 } 290 publicvoid setMaps(Map 291 this.maps = maps; 292 } 293 @Override 294 public String execute() throws Exception { 295 // TODO Auto-generated method stub 296 return SUCCESS; 297 } 298 }
Java代码 299 Key_maps=java.lang.String // Key_ 固定 后面为action的Map属性名 300 Element_maps=com.sh.pojo.Register
Html代码 301 302 303
304 305 306 307 308 309 310 311 312 313
314 317 320 323 326 329 330 331 332 333
Html代码 334 335
336 337 338 339 340 341 342 343 ===========遍历所有的=========
344 345
346 349 352 355 358 361 362 363 364 ===========单独去其中的一个= (知道其中的key=0)========
365
366 369 372 375 378 381 382 事例: Jsp: value="%{sysConfigs[#stat.index].id}" /> value="%{sysConfigs[#stat.index].name}" /> value="%{sysConfigs[#stat.index].info}" />
id='edit___cfg_basehost'value=" |