bruce_sky
卡卡西CC
2012-07-10 17:14
采纳率: 100%
浏览 206
已采纳

Struts2 Push Tag 引发的问题

按照Struts官网上的CRUD例子,自己实践了一下,结果报错:
[b]tag 'push', field 'value': You must specify a value to push on the stack.[/b]

[code="java"]
exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /register.jsp at line 16

13:
14:


15:
16:
17:
18:
19:

Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:73)

root cause

tag 'push', field 'value': You must specify a value to push on the stack. Example: person - [unknown location]
org.apache.struts2.components.Component.fieldError(Component.java:230)
org.apache.struts2.components.Component.findValue(Component.java:351)
org.apache.struts2.components.Push.start(Push.java:128)
org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:53)
org.apache.jsp.register_jsp._jspx_meth_s_005fpush_005f0(register_jsp.java:209)
org.apache.jsp.register_jsp._jspx_meth_s_005fform_005f0(register_jsp.java:179)
org.apache.jsp.register_jsp._jspService(register_jsp.java:120)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

[/code]

错误页面部分代码:
[code="java"]





headerValue="Select" label="Select a country" />

label="Would you like to join our mailing list?" />

/s:push
/s:form
[/code]

Action部分的代码:
[code="java"]
private User user = new User();
private List userList = new ArrayList();
private UserDAO userDAO = new UserDAOImpl();

public void setUser(User user) {
    this.user = user;
}

public User getUser() {
    return user;
}

[/code]

"user" 已声明且已有 set/get 方法

User类:
[code="java"]
package com.vaannila.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="USERDEMO")
public class User {

private Long id;
private String name;
private String gender;
private String country;
private String aboutYou;
private Boolean mailingList;

@Id
@GeneratedValue
@Column(name="ID")    
public Long getId() {
    return id;
}
public void setId(Long id) {
    this.id = id;
}

@Column(name="NAME")
public String getName() {
    return name;
}
public void setName(String name) {
    this.name = name;
}

@Column(name="GENDER")
public String getGender() {
    return gender;
}
public void setGender(String gender) {
    this.gender = gender;
}

@Column(name="COUNTRY")
public String getCountry() {
    return country;
}
public void setCountry(String country) {
    this.country = country;
}

@Column(name="ABOUTYOU")
public String getAboutYou() {
    return aboutYou;
}
public void setAboutYou(String aboutYou) {
    this.aboutYou = aboutYou;
}

@Column(name="MAILINGLIST")
public Boolean getMailingList() {
    return mailingList;
}
public void setMailingList(Boolean mailingList) {
    this.mailingList = mailingList;
}

}
[/code]

自己检查好几遍不知道错误出在哪里,请明白人指点。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • works001
    works001 2012-07-10 17:51
    已采纳

    应该是没有值 获得不到user的值造成塞不到

    另外你可以看看http://www.linuxso.com/linuxbiancheng/12641.html 里面的push部分

    点赞 评论

相关推荐