gpt4 book ai didi

java - 警告 : Could not find action or result - Struts2

转载 作者:太空宇宙 更新时间:2023-11-04 15:08:38 24 4
gpt4 key购买 nike

我目前正在开发一个基于struts2+hibernate+spring的应用程序,我遇到了以下问题,在我单击“regist.jsp”页面中的提交按钮后,RegistAction.java接收请求,并返回“成功的状态,但我不确定它是否进入了这种状态。

struts.xml 文件有问题吗?

**** 登录控制台**

?? 08, 2014 10:53:18 ?? com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
WARNING: Could not find action or result
No result defined for action org.leegang.action.RegistAction and result success
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:373)
...

?? 08, 2014 10:53:18 ?? com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
SEVERE: Exception occurred during processing request: No result defined for action org.leegang.action.RegistAction and result success
No result defined for action org.leegang.action.RegistAction and result success
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:373)
.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:744)

* struts.xml**

<?xml version="1.0" encoding="GBK"?>
<!-- 指定Struts2配置文件的DTD信息 -->
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<!-- Struts2配置文件的根元素 -->
<struts>
<!-- 配置了系列常量 -->
<constant name="struts.custom.i18n.resources" value="messageResource"/>
<constant name="struts.i18n.encoding" value="GBK"/>

<package name="lee" extends="struts-default">
<!-- 定义处理用户请求的Action,指定该Action的实现类-->
<action name="regist" class="org.leegang.action.RegistAction" >
<result name="error">/error.jsp</result>
<result name="success">/welcome.jsp</result>
</action>

<action name="home">
<result>/regist.jsp</result>
</action>

</package>
</struts>

regist.jsp*

<%@ page language="java" contentType="text/html; charset=GBK"%>

<html>
<head>
<title>用户注册</title>
</head>
<body>
<form action="regist.action" method="post">
<table align="center">
<caption><h3>用户注册</h3></caption>
<tr>
<td>用户名:<input type="text" name="username"/></td>
</tr>
<tr>
<td>年&nbsp;&nbsp;龄:<input type="text" name="age"/></td>
</tr>
<tr align="center">
<td colspan="2"><input type="submit" value="注册"/><input type="reset" value="重填" /></td>
</tr>
</table>
</form>
</body>
</html>

最佳答案

"/" 命名空间添加到 package 元素:

<package name="lee" extends="struts-default" namespace="/">
...
</package>

关于java - 警告 : Could not find action or result - Struts2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21641391/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com