开发者社区> 问答> 正文

struts2 action 配置问题?报错

 由于在strus框架单个项目测试action映射报错,单独建立一个原始的struts项目,在action映射还是报错,送上截图--》

项目目录:

web.xml 截图:

struts.xml截图:

action截图:

index.jsp截图:

 

myeclipse 8.5 自带的struts jar包:


报错:

警告: Could not find action or result
No result defined for action net.hsf.action.LandAction and result input
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:364)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)

郁闷啊,不知哪里搞错了,google的答案试了也不行呐。 在action里直接retunt input,struts配置的result name也是input啊? 还有一点郁闷的,在配置action后指定method为 test,映射的时候走的还是execute方法,不进test方法? 先帮我看看第一个问题吧,怎么能这样呢。。。。

展开
收起
爱吃鱼的程序员 2020-06-22 20:34:56 496 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    换个版本看看命名空间问题,在配置文件中配上namespace属性返回逻辑结果名的时候,你先试试success,看如何?然后再测试另外也可以参考楼上的意见,加上namespace限制,LS说得对,给你个例子参考<preclass="brush:xml;toolbar:true;auto-links:false;"><struts><constantname="struts.devMode"value="true"/><packagename="s2"namespace="/"extends="struts-default"><actionname="helloworld"class="com.zhurou.HelloAction"method="execute"><resultname="success">/WEB-INF/page/hello.jsp</result></action></package></struts>你如果将form改为action="/land"可行,即说明命名空间问题!

    strutsjar包好像有些会冲突,这是我用到的struts2基本jar包,有其他需求在添加

    <imgsrc="http://static.oschina.net/uploads/space/2013/0405/191109_Npbx_922543.jpg"alt=""/>

    struts最好自己下载,选自己需要的jar包。

    <divclass="ref">

    引用来自“经典忧郁”的答案

    <divclass=ref_body>命名空间问题,在配置文件中配上namespace属性<divclass="ref">

    引用来自“阿尔法兽”的答案

    <divclass=ref_body>LS说得对,给你个例子参考<preclass="brush:xml;toolbar:true;auto-links:false;"><struts><constantname="struts.devMode"value="true"/><packagename="s2"namespace="/"extends="struts-default"><actionname="helloworld"class="com.zhurou.HelloAction"method="execute"><resultname="success">/WEB-INF/page/hello.jsp</result></action></package></struts><divclass="ref">

    引用来自“心有未来”的答案

    <divclass=ref_body>你如果将form改为action="/land"可行,即说明命名空间问题!好吧!终归还是命名空间问题...<divclass="ref">

    引用来自“万里码”的答案

    <divclass=ref_body>

    strutsjar包好像有些会冲突,这是我用到的struts2基本jar包,有其他需求在添加

    <imgsrc="http://static.oschina.net/uploads/space/2013/0405/191109_Npbx_922543.jpg"alt=""/>

    struts最好自己下载,选自己需要的jar包。

    2020-06-22 20:35:14
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载