struts.xml:
<struts>
<constant name="struts.devMode" value="true"></constant>
<package name="user" extends="struts-default" namespace="/user">
<action name="user" class="com.zjw.web.action.user.UserAction">
<result name="success">/AddSuccess.jsp</result>
</action>
</package>
</struts>UserAction:
public class UserAction extends ActionSupport { /**
*
*/ private User user; public String add() {
System.out.println("name=" + user.getName());
System.out.println("age=" + user.getAge());
return SUCCESS;
} public User getUser() {
return user;
} public void setUser(User user) {
this.user = user;
}
}web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
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_3_0.xsd">
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping></web-app>我发送如下请求 localhost:8080/Struts2_001/user/user!add?name=tom&age=18
控制台能够输出 name和age的值 但是接下来就会报错
Struts has detected an unhandled exception:
Messages:
No result defined for action com.zjw.web.action.user.UserAction and result success
Stacktraces
No result defined for action com.zjw.web.action.user.UserAction and result success
但是当把namespace的值改成"/"就能正常运行,求各位大神帮帮忙,在不改namespace的情况下 如何解决?谢谢
Struts
<struts>
<constant name="struts.devMode" value="true"></constant>
<package name="user" extends="struts-default" namespace="/user">
<action name="user" class="com.zjw.web.action.user.UserAction">
<result name="success">/AddSuccess.jsp</result>
</action>
</package>
</struts>UserAction:
public class UserAction extends ActionSupport { /**
*
*/ private User user; public String add() {
System.out.println("name=" + user.getName());
System.out.println("age=" + user.getAge());
return SUCCESS;
} public User getUser() {
return user;
} public void setUser(User user) {
this.user = user;
}
}web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
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_3_0.xsd">
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping></web-app>我发送如下请求 localhost:8080/Struts2_001/user/user!add?name=tom&age=18
控制台能够输出 name和age的值 但是接下来就会报错
Struts has detected an unhandled exception:
Messages:
No result defined for action com.zjw.web.action.user.UserAction and result success
Stacktraces
No result defined for action com.zjw.web.action.user.UserAction and result success
但是当把namespace的值改成"/"就能正常运行,求各位大神帮帮忙,在不改namespace的情况下 如何解决?谢谢
Struts
localhost:8080/Struts2_001/user/user!add.action?name=tom&age=18
这里就应该直接进不去方法体。这个线不看。
但是根据异常信息显然是没有找到对应的 对应的action , 在name="success"的result中 配置的页面是/AddSuccess.jsp ,那么这个页面必须在Webcontent或者WebRoot根目录,至于去掉命令空间可行的原因可能是 加了struts2-convertion.jar 这个jar包 按照约定找页面。
age=18
2013-7-30 20:47:01 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
严重: Could not find action or result
/Struts2_0800_DomainModleParamInput/user/user!add.action?user.name=tom&user.age=18
No result defined for action com.zjw.web.action.user.UserAction and result success值可以读到,但还是跳转不到页面,太诡异了去, 我win7的系统 求帮忙
<action name="user" class="com.zjw.web.action.user.UserAction" method="add">
<result name="success">/AddSuccess.jsp</result>
</action>