<struts>
<package name="default" namespace="/" extends="struts-default">
<action name="ZouYiGe" class="net.liulixin.ListAction" method="input">
<result name="input">list.jsp</result>
</action>
<action name="ZouLiangGe" class="net.liulixin.ListAction" >
<result name="success">NewFile.jsp</result>
</action>
</package>
</struts>
package net.liulixin;
import java.util.ArrayList;
import java.util.List;
import com.opensymphony.xwork2.ActionSupport;
public class ListAction extends ActionSupport {
private List<ListObject> myList;
private String mySelection;
public String input() {
myList = new ArrayList<ListObject>();
myList.add(new ListObject("val1","丁一轩"));
myList.add(new ListObject("val2","男子龙"));
myList.add(new ListObject("val3","苏一辰"));
mySelection = "val2";
return INPUT;
}
public String execute() {
// Do stuff with list here
return SUCCESS;
}
public List<ListObject> getMyList() {
return myList;
}
public void setMyList(List<ListObject> newList) {
this.myList = newList;
}
public String getMySelection() {
return mySelection;
}
public void setMySelection(String newSelection) {
this.mySelection = newSelection;
}
}
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>西安Java培训</title>
</head>
<body>
<s:iterator value="myList">
<s:radio theme="simple" name="mySelection" list="#{key:label}" />
<br>
</s:iterator>
</body>
</html>
原文:http://ddubbya.blogspot.com/2011/02/struts2-vertical-radio-list-without.html
源代码:http://pan.baidu.com/share/link?shareid=475883&uk=3878681452