本帖最后由 u013119744 于 2014-02-28 16:18:49 编辑

解决方案 »

  1.   

    你把包 导完了没  是不是少一个struts的核心包啊 大概是  struts-core-XXX.jar
      

  2.   

    这个是我的struts.xml其中引用的类代码为package org.crazyit.app.action;
    import com.opensymphony.xwork2.ActionContext;
    import com.opensymphony.xwork2.ActionSupport;public class LoginAction extends ActionSupport
    {

    private String username;
    private String password;

    public String getUsername()
    {
    return username;
    }
    public void setUsername(String username)
    {
    this.username = username;
    }

    public String getPassword()
    {
    return password;
    }
    public void setPassword(String password)
    {
    this.password = password;
    }
    public String execute() throws Exception
    {
    if (getUsername().equals("crazyit.org")
    && getPassword().equals("leegang") )
    {
    ActionContext.getContext().getSession()
    .put("user" , getUsername());
    return SUCCESS;
    }
    else
    {
    return ERROR;
    }
    }
    }
      

  3.   

    好吧!我也是新手,我的struts.xml的核心过滤器你这样写可以吗?
      

  4.   

    说错了,是web.xml中的  <!-- struts2核心过滤器配置开始 -->
      <filter>
       <filter-name>struts</filter-name>
       <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
      </filter>
      
      <filter-mapping>
       <filter-name>struts</filter-name>
       <url-pattern>/*</url-pattern>
      </filter-mapping>
      <!-- struts2核心过滤器配置结束 --> 
      

  5.   

    你把jsp的第一行的一些空格去掉"text/html"后面不要空格写
    检查下你的JSP页面,//在struts页面上是需要带入.action的,配置文件不要,还有你的名称空间加上
    还有就是你的<s:form action="login.action" namescapace="/" >
      

  6.   

    楼主把lib下的jar截个图贴出来
      

  7.   

    应该是struts2的过滤器配置错了吧
      

  8.   

    谢谢大家了 已经搞好了 是由于我lib下面的jar出现了问题