您的位置:程序门 -> java -> 架构、设计



高手请留步,新手struts2问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


高手请留步,新手struts2问题[无满意答案结贴]
发表于:2008-01-10 16:37:48 楼主
我比着例子做的,却无法执行,报error   404--not   found错误,
action:
package   com.test.action;

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{
return   success;
}
}
web.xml:
<?xml   version="1.0"   encoding="utf-8"?>
<web-app   version="2.4"  
xmlns="http://java.sun.com/xml/ns/j2ee"  
xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"  
xsi:schemalocation="http://java.sun.com/xml/ns/j2ee  
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
   
    <display-name> struts   blank </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>
struts.xml
<!doctype   struts   public

                "-//apache   software   foundation//dtd   struts   configuration   2.0//en"

                "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<package   name="abc"   namespace="/abc"   extends="struts-default">
<action   name="loginaction"   class="com.text.action.loginaction">
<result> /success.jsp </result>
</action>
</package>

</struts>
用的myeclipse6.0+weblogic9+jdk5.0
struts.xml文件放在webroot\web-inf\classes\下
麻烦请指教!!!
发表于:2008-01-11 08:18:201楼 得分:0
大家帮忙顶一下,路过有分!!
发表于:2008-01-11 08:30:192楼 得分:0
没能力。。。只能给帖子张人气!!
发表于:2008-01-11 10:23:333楼 得分:0
是不是jsp路径写的有问题啊,或者jsp的位置不对
发表于:2008-01-11 13:58:364楼 得分:0
<result>   /success.jsp   </result>  
不对吧,没有说明成功后返回哪里啊?
以下是我的做法(我用的是webwork2):
<result   name='success'   type='forward'>   /success.jsp   </result>  
发表于:2008-01-11 18:11:365楼 得分:0
index.jsp   这个页面应该和目录web-inf同属一个目录

<welcome-file-list>  
                                <welcome-file>   /index.jsp   </welcome-file>  
                </welcome-file-list>
发表于:2008-01-11 18:13:126楼 得分:0
btw:上个回复红色不明显,应该有哪个斜杠吧,struts2的写法不知道,感觉web.xml和路径可能有问题


快速检索

最新资讯
热门点击