[英]WARNING: Could not find action or result - Struts2
我目前正在開發基於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>年 齡:<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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.