Struts中传参中的DMI出错问题

    在练习中,建立了一个项目Struts_001,将相关Jar包放入WEB-INF的lib文件夹中,并配置好web.xml。

index.jsp作为访问首页,

index.jsp的中采用如下代码传递参数

传输参数问题,
   

   
    姓名:
   
   

创建action包,在其中创建UserAction.java  代码如下:

package action;


import com.opensymphony.xwork2.ActionSupport;


public class UserAction extends ActionSupport{
private String name;
public String add(){
System.out.println("name="+name);
return SUCCESS;
}
public String getName() {
return name;
}
public void setName(String name) {Struts中传参中的DMI出错问题_第1张图片
this.name = name;
}

}


在创建Sruts.xml   代码如下:


    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">





   
   

    
       
        
       
           
            /User_add_success.jsp
           

       

              
   



   



再创建User_add_success.jsp显示操作成功页面


输入http://localhost:8080/Struts_001显示页面

Struts中传参中的DMI出错问题_第2张图片

输入abc点击提交

转到如下页面

Struts Problem Report

Struts has detected an unhandled exception:

Messages: There is no Action mapped for namespace /actions and action name user!add.

Stacktraces

There is no Action mapped for namespace /actions and action name user!add. - [unknown location]
    com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:177)
    org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
    org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
    com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:458)
    org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:76)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    java.lang.Thread.run(Thread.java:722)
    
此外,  将其设置为True变为开发模式,修改代码后不用重启Tomcat。

你可能感兴趣的:(Struts)