不行啊,同样的错误,, HTTP Status 404 - /HelloWorld/index.action--------------------------------------------------------------------------------type Status reportmessage /HelloWorld/index.actiondescription The requested resource (/HelloWorld/index.action) is not available. --------------------------------------------------------------------------------Apache Tomcat/7.0.21
把index.jsp改为: <form method="post" action="index.action">struts.xml ... <action path="/HelloWorld" name="index" class="HelloWorld"> <result name="success">success.jsp</result> <result name="error">error.jsp</result> </action> 会出现下面这个错误 Attribute "path" must be declared for element type "action".
HTTP Status 404 - /HelloWorld/index.action--------------------------------------------------------------------------------type Status reportmessage /HelloWorld/index.actiondescription The requested resource (/HelloWorld/index.action) is not available.
--------------------------------------------------------------------------------Apache Tomcat/7.0.21
<form method="post" action="index.action">struts.xml
...
<action path="/HelloWorld" name="index" class="HelloWorld">
<result name="success">success.jsp</result>
<result name="error">error.jsp</result>
</action>
会出现下面这个错误
Attribute "path" must be declared for element type "action".
<action name="index" class="包名.HelloWorld">
struts2里面好像说是可以用普通类来作为action的吗,如果要继续某个action,不知道是哪个包里,哪个类,我试一下??
你把浏览器地址栏的URL粘贴出来,没准儿是地址写错了,或者是端口号写错了。
org.apache.struts2.dispatcher.FilterDispatcher
单击提交按钮后,地址栏上显示的是http://localhost:8080/HelloWorld/index.action
然后下面就是上面说的那种错误提示了。。
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd"><struts> <package name="default" namespace="/" extends="struts-default"> <action name="index" class="HelloWorld">
<result name="success">success.jsp</result>
<result name="error">error.jsp</result>
</action>
</package></struts>将其中的index改成HelloWorld即可
我已经改了<form method="post" action="index">
你对Struts配置文件修改后,有没有重启一下?
<body>
Hello World!
<form method="post" action="HelloWorld.action">
<input type="text" name="username" />
<input type="submit" name="submit" />
</form>
</body>
</html>将它HelloWorld.action改成index.action看看
{
private String username;
public void setUsername(String username)
{
this.username = username;
}
public String getUsername()
{
return username;
}
public String execute()
{
if(getUsername().equals(""))
{
System.out.println("no String input!");
return "error";
}
else
{
System.out.println(getUsername());
return "success";
}
}
}
将你的java类写成这样试试
我不知道那个struts.xml中的那个<package>主要做什么的,<form action="index.action">不知道是不是跟<package>设置的有关,但我把action=""都改成各种各样的,都还是不行,看看是不是跟它这个有关???
谢谢各路大神的关注。。