本帖最后由 AA5279AA 于 2013-01-25 13:59:55 编辑

解决方案 »

  1.   

    form的action地址不是login
    <form action="login.action" method="get"> 
      

  2.   

    <form action="login!logins" method="get">    这样试试
      

  3.   

    我的struts.xml中也是login,加或者不加效果都是一样的。。
    <action name="login" method="logins" class="cn.test.springTest.LoginAction">
                         
    </action>
      

  4.   

    在struts配置文件配置了namespace="/resources",<form action="login" method="get">应该要指定namespace才对,不然默认是到namespace=“/”里面找吧?是不是这样?
      

  5.   

    不加找不到action的即使你在web.xml里配置的url-pattern是什么
      

  6.   

    不加不规范我是成人的,但是实际上是能找得到的。。
    几乎一样的代码,这次确成功了。。不知道是不是编译工具的大姨妈来了。。
    崩溃<html>
    <head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
    this form
    <form action="loginsss" method="get">
    姓名:<input name="name" type="text"></input><br>
    密码:<input name="password" type="password"></input><br>
    <input type="submit" value="注册"></input>
    </form>
    </body>
    </html><struts>
    <package name="myPackage" namespace="/resources" extends="struts-default">
    <!-- <default-class-ref class=""/> -->
    <global-results>
    <result name="success">/resources/loginsuccess.jsp</result>
    <result name="error">/resources/error.html</result>
    </global-results>
    <action name="loginsss" method="logins" class="cn.test.springTest.LoginAction">

    </action>
    <action name="register" method="execute" class="cn.test.springTest.RegisterAction">

    </action>

    </package>
    </struts>
    public class LoginAction extends ActionSupport{
    String name;
    String password;
    public String logins(){

    System.out.println("in login");
    //ActionContext ac = ActionContext.getContext();

    HttpServletRequest request=ServletActionContext.getRequest();
    try {
    request.setCharacterEncoding("UTF-8");
    } catch (UnsupportedEncodingException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    request.setAttribute("name", name);
    request.setAttribute("password", password);
    System.out.println("in login");

    if((name!=null)&&(password!=null)){
    System.out.println("用户信息已经接受");
    System.out.println("用户名为"+name+",密码为:"+password);
    return SUCCESS;

    }else{
    System.out.println("用户名或者密码为空");
    return ERROR;
    }

    }




    public String getName() {
    return name;
    }
    public void setName(String name) {
    this.name = name;
    }
    public String getPassword() {
    return password;
    }
    public void setPassword(String password) {
    this.password = password;
    }

    }
    web.xml:<?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <session-config>  
        <session-timeout>0</session-timeout>  
    </session-config>
    <!--把Struts的Action类交给Spring来 管理, 配置spring的监听器 -->
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:/spring/*.xml</param-value>
    </context-param>
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
    <listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener> <filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
    <param-name>encoding</param-name>
    <param-value>UTF-8</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
    <!--Struts2所有的配置被整合在一个Filter里面,配置Struts2的过滤器 -->
    <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
    <error-page>
    <error-code>404</error-code>
    <location>/page/index.jsp</location>
    </error-page>
    <error-page>
    <error-code>500</error-code>
    <location>/page/index.jsp</location>
    </error-page>
    <welcome-file-list>
    <welcome-file>/page/index.jsp</welcome-file>
    </welcome-file-list>

    </web-app>
      

  7.   

    你用/*可以不加.action确保你当前这jsp的路径是不是在/resources下
      

  8.   

    <html>
    <head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
    <form action="/resources/login.action" method="get">
    姓名:<input name="name" type="text"></input><br>
    密码:<input name="password" type="password"></input><br>
    <input type="submit" value="注册"></input>
    </form>
    </body>
    </html><form action="/resources/login.action" method="get">
      

  9.   

    我以前遇到这样的问题,怎么看都是没错的,在jsp页面中,Form中的action="Login" 对应的struts.xml中<action name="Login"..>
    Action首字母大写可避免此问题,我的是这样的问题。
      

  10.   

    我会告诉你我搭建ssh时候因为jsp上没写s得taglib 纠结了一周得时间么
      

  11.   

    <action name="login" method="logins" class="cn.test.springTest.LoginAction">
    木有result
    你这个地方
     if((name!=null)&&(password!=null)){
                System.out.println("用户信息已经接受");
                System.out.println("用户名为"+name+",密码为:"+password);
                return SUCCESS;
    返回SUCCESS这不是扯淡吗。修改成return null;
      

  12.   

    我晕。。
    看上面有木有:
     <global-results>
                <result name="success">/resources/loginsuccess.jsp</result>
                <result name="error">/resources/error.html</result>
            </global-results>
    这些东西干嘛用的你应该知道吧?
      

  13.   

    LZ的问题  我也遇到过 没有办法的办法 把方法名字改了ok了  问题了一下热 说是hibernate缓存有记忆功能... 我也清理过缓存 虽这说法不能让我信服,但改了名字确实可以....  同求问题之根本....
      

  14.   

    改为这个试试:<form action="resources/login.action" method="get">