wlq530 2011-10-13 14:05
浏览 448
已采纳

简单问题struts2标签显示不出来action里的数据

UsersAction.java:
[code="java"]public String getAllUserInfo() throws Exception
{
list = userService.getAllUserInfo();
for(Users userInfo : list)
{
System.out.println(userInfo.getUsername());
}
setList(list);
return SUCCESS;
}[/code]

UserService.java:
[code="java"]public interface UserService {

public int insertUsers(Users users);
public List<Users> getAllUserInfo();

}[/code]

UserServiceImpl.java:[code="java"]public class UserServiceImpl implements UserService {

private DataDaoService baseDao;

public DataDaoService getBaseDao() {
    return baseDao;
}
public void setBaseDao(DataDaoService baseDao) {
    this.baseDao = baseDao;
}
public int insertUsers(Users users) {

    return baseDao.saveObject("insertUsers", users);
}
  public List<Users> getAllUserInfo(){
      return baseDao.getAllUserInfo();  
  }

}[/code]

DataDaoService.java:
[code="java"]public interface DataDaoService {

public int saveObject(String methodName,Object object);
public List<Users> getAllUserInfo();

}[/code]
DataDaoServiceimpl.java[code="java"]public class DataDaoServiceimpl extends SqlMapClientDaoSupport implements DataDaoService{

public int saveObject(String methodName,Object object)
{
    return (Integer)this.getSqlMapClientTemplate().insert(methodName,object);
}

@SuppressWarnings("unchecked")
public List<Users> getAllUserInfo() {
    // TODO Auto-generated method stub
    return getSqlMapClientTemplate().queryForList("selectAllUsers");    
}

}[/code]
Users.java:
[code="java"]public class Users {

private int id;
private String username;
private String userpass;
private String sex;
private int age;
private String remark;
public int getid() {
    return id;
}
public void setid(int id) {
    this.id = id;
}
public String getUsername() {
    return username;
}
public void setUsername(String username) {
    this.username = username;
}
public String getUserpass() {
    return userpass;
}
public void setUserpass(String userpass) {
    this.userpass = userpass;
}
public String getSex() {
    return sex;
}
public void setSex(String sex) {
    this.sex = sex;
}
public int getAge() {
    return age;
}
public void setAge(int age) {
    this.age = age;
}
public String getRemark() {
    return remark;
}
public void setRemark(String remark) {
    this.remark = remark;
}

}
[/code]
User.xml:

[code="java"]<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE sqlMap

PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"

"http://ibatis.apache.org/dtd/sql-map-2.dtd">


<!-- Use type aliases to avoid typing the full classname every time. -->

<!-- Result maps describe the mapping between the columns returned
from a query, and the class properties. A result map isn't
necessary if the columns (or aliases) match to the properties
exactly. -->







<!-- Select with no parameters using the result map for Account class. -->

select * from Users

<!-- A simpler select example without the result map. Note the
aliases to match the properties of the target result class. -->

select id,username,userpass,sex,age,remark from Users where id = #id#

<!-- Insert example, using the Account parameter class -->

insert into Users (username,userpass,sex,age,remark)
values(#username#, #userpass#, #sex#, #age#, #remark#)

<!-- Update example, using the Account parameter class -->

update Users setusername = #username#,userpass = #userpass#, age = #age# where id = #id#

<!-- Delete example, using an integer as the parameter class -->

delete from Users where id = #id#

[/code]

index.jsp:
[code="java"]
<%@ 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">







/s:iterator


[/code]

struts-users.xml:
[code="java"]<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<!-- 让spring管理struts2 -->

<!-- 更改处理后缀 -->
<!--


/index.jsp
/reg.jsp
/404.html

-->

   <package name="default" extends="struts-default">
    <action name="UserAction" class="userAction" method="getAllUserInfo">
        <result name="success" >/index.jsp</result>
    </action>
</package>

[/code]

错误如下:type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.NoSuchMethodError: com.opensymphony.xwork2.util.ValueStack.findValue(Ljava/lang/String;Z)Ljava/lang/Object;
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)

root cause

javax.servlet.ServletException: java.lang.NoSuchMethodError: com.opensymphony.xwork2.util.ValueStack.findValue(Ljava/lang/String;Z)Ljava/lang/Object;
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:852)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
org.apache.jsp.index_jsp._jspService(index_jsp.java:81)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)

root cause

java.lang.NoSuchMethodError: com.opensymphony.xwork2.util.ValueStack.findValue(Ljava/lang/String;Z)Ljava/lang/Object;
org.apache.struts2.components.Component.findValue(Component.java:255)
org.apache.struts2.components.IteratorComponent.start(IteratorComponent.java:269)
org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:53)
org.apache.jsp.index_jsp._jspx_meth_s_005fiterator_005f0(index_jsp.java:100)
org.apache.jsp.index_jsp._jspService(index_jsp.java:71)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.

  • 写回答

13条回答 默认 最新

  • AngelAndAngel 2011-10-13 14:59
    关注

    [quote]java.lang.NoSuchMethodError: [/quote]
    那的确就是包出了问题,检查与struts2相关的包

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(12条)

报告相同问题?

悬赏问题

  • ¥15 平板录音机录音问题解决
  • ¥15 请问维特智能的安卓APP在手机上存储传感器数据后,如何找到它的存储路径?
  • ¥15 (SQL语句|查询结果翻了4倍)
  • ¥15 Odoo17操作下面代码的模块时出现没有'读取'来访问
  • ¥50 .net core 并发调用接口问题
  • ¥15 网上各种方法试过了,pip还是无法使用
  • ¥15 用verilog实现tanh函数和softplus函数
  • ¥15 Hadoop集群部署启动Hadoop时碰到问题
  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启