首页 新闻 会员 周边

struts 的action跳转问题

0
[已关闭问题] 关闭于 2017-08-25 18:17

提交表单时报404,新手求助啊

Eclipse控制台能打印出来,但jsp页面找不到

index.jsp submit到success.jsp

1.Action

public class ListAction extends ActionSupport {

/**
*
*/
private static final long serialVersionUID = 1L;
private List<User> users;
private String info;

public String getInfo() {
return info;
}
public void setInfo(String info) {
this.info = info;
}
public List<User> getUsers() {
return users;
}
public void setUsers(List<User> users) {
this.users = users;
}

@Override
public String execute() throws Exception {
for (User user : users) {
System.out.println("Name:" + user.getName()+" " + "Age:" + user.getAge() +" " +
"Tel:" + user.getTel());
}
return SUCCESS;
}

}

2.user类

public class User {
private String name;
private int age;
private String tel;

....实现了get和set方法以及构造方法

3.index.jsp

<body>
<center>
<s:form action="list!show.action">
<table>
<tr>
<td/>
<td>first:</td>
<td>second:</td>
</tr>
<tr>
<td>Name:</td>
<td><s:textfield name="users[0].name" theme="simple"></s:textfield></td>
<td><s:textfield name="users[1].name" theme="simple"></s:textfield></td>
</tr>
<tr>
<td>Age:</td>
<td><s:textfield name="users[0].age" theme="simple"></s:textfield></td>
<td><s:textfield name="users[1].age" theme="simple"></s:textfield></td>
</tr>
<tr>
<td>Tel:</td>
<td><s:textfield name="users[0].tel" theme="simple"></s:textfield></td>
<td><s:textfield name="users[1].tel" theme="simple"></s:textfield></td>
</tr>
<tr>
<td colspan="3">
<s:submit></s:submit>
</tr>
</table>
</s:form>
</center>
</body>

4.success.jsp

<body>
<center>
Name:<s:property value="users[0].name"/>
Age:<s:property value="users[0].age"/>
Tel:<s:property value="users[0].tel"/>
Name:<s:property value="users[1].name"/>
Age:<s:property value="users[1].age"/>
Tel:<s:property value="users[1].tel"/>
</center>
</body>

5.struts.xml

<struts>
<package name="default" namespace="/" extends="struts-default">
<action name="list" class="com.wangzhihai.action.ListAction">
<result>/success.jsp</result>
</action>
</package>
</struts>

刺客五六七的主页 刺客五六七 | 菜鸟二级 | 园豆:204
提问于:2016-09-27 14:42
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册