发帖的时候写错了点东西,struts2.xml文件名写错了,应该是struts.xml

解决方案 »

  1.   

    没看见你的namespace呢,好些时候找不到都是因为路径的问题
      

  2.   

    <form action="Login.action" method="post">
    这个路径写错了。
     <package name="strutsqs" extends="struts-default">
    既然package指定name了。在访问的时候,就得把这个加上
    改为 <form action="strutsqs/Login.action" method="post"> 试试吧!
      

  3.   

    我是按照一个教程上写的,教程上也没写,如果没写namespace,那我运行的地址http://localhost:8080/Struts2qs这个应该也没错啊。
      

  4.   

     class="LoginAction"应改为class="" 你的action都没有的
      

  5.   

    再把web.xml中的index.jsp改成Login.jsp,运行时直接进入登陆界面
      

  6.   

    包中加上namespace属性,在页面访问action时action前面要加上namespace的属性值,比如:  <package name="strutsqs" extends="struts-default" namespace=“ss”>,则在页面上访问的时候<form action="/ss/Login.action" method="post">
      

  7.   

    再有在form中的访问路径上加上${pageContext.request.contextPath}获取项目根路径
      

  8.   

    <package>中不写namespace是可以的,  不写它默认为空。楼主应该有那个LoginAction的。楼主,看下的web.xml。  一个 <filter-name>struts2</filter-name>
      另一个你是这样写的 <filter-name>Struts2</filter-name>大小写。
               
                              
      

  9.   

    org.apache.Struts2.dispatcher.FilterDispatcher应该没有这个包吧
    你确认你启动的时候没有报错
      

  10.   

    要是直接http://localhost:8080/Struts2qs,应该是404,要是后者的话,应该是你web.xml配置的问题,你可以试着吧你WEB-INF下的web.xml删除掉,在直接访问应该就会有内容显示了。可能是你web.xml中struts种filter标签name不一致的缘故/
      

  11.   

    login.jsp <form action="ddd.action" method="post">
        <div class="nn"><input type="text" name="hello" /></div>
        <div class="nn"><input type="password" name="hi" /></div>
        <div class="nn"><input type="submit" value="提交"></div>
     </form>
    struts.xml<?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"><struts>
    <package name="test" extends="struts-default" namespace="/">
    <action name="ddd" class="qaction.kkk" method="sss">
    <result name="success" >
    /success.jsp
    </result>
    </action>

    </package>
    </struts>
    qaction包下kkk.javapackage qaction;import com.opensymphony.xwork2.ActionSupport;
    import javax.persistence.Entity;
    public class kkk extends ActionSupport {
    private String hello;
    public String getHello() {
    return hello;
    }
    public void setHello(String hello) {
    this.hello = hello;
    }
    public String getHi() {
    return hi;
    }
    public void setHi(String hi) {
    this.hi = hi;
    }
    private String hi;


    public String sss()
    {
    if(hello.equals("hhh")&&hi.equals("nnn"))
    return SUCCESS;
    else
    return "nono";
    }
    }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">
      <display-name></display-name>
      
    <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>
     
      <welcome-file-list>
      
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
    </web-app>
    Struts2的包
    commons-fileupload-1.2.1.jar
    commons-io-1.3.2.jar
    commons-logging-1.1.jar
    freeer-2.3.13.jar
    ognl-2.6.11.jar
    struts2-core-2.1.6.jar
    xwork-2.1.2.jar
    这样有出现404
    没配置struts2 tomcat就是true  一配置tomcat就false