“找不到操作或结果”在Struts中
我目前正在使用 jquery+struts 插件创建一个 Web 应用程序。它还使用休眠。我已经有两个网页,另一个运行得很好,但是当我创建另一个网页时,它抛出一个错误,指出无法找到该操作。错误是:
ERROR (org.apache.struts2.dispatcher.Dispatcher:38) - Could not find action or result
/mims_agchem/index.action
No result defined for action com.agchem.mims.actions.Index and result success
在 com.opensymphony.xwork2.DefaultActionInvocau.executeResult(DefaultActionInvocau.java:375) 在 com.opensymphony.xwork2.DefaultActionInvocau.invoke(DefaultActionInvocau.java:277) 在 com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176) 在 com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 在 com.opensymphony.xwork2.DefaultActionInspiration.invoke(DefaultActionInitation.java:248) 在 com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263) 在org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68) 在 com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 在 com.opensymphony.xwork2.DefaultActionInvocau.invoke(DefaultActionInvocau.java:248)
这些是我的代码:
struts.xml
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="true" />
<package name="admin" namespace="/admin" extends="hibernate-default,json-default,struts-default">
<interceptors>
<interceptor-stack name="showcaseStack">
<interceptor-ref name="defaultStackHibernate"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="showcaseStack"/>
<action name="*" class="com.agchem.mims.actions.admin.{1}">
<result>/jsp/admin/{1}.jsp</result>
<result name="redirect" type="redirect">${redirectUrl}</result>
</action>
</package>
<package name="general" namespace="/" extends="hibernate-default,json-default,struts-default">
<interceptors>
<interceptor-stack name="showcaseStack">
<interceptor-ref name="defaultStackHibernate"/>
</interceptor-stack>
</interceptors>
<action name="index" class="com.agchem.mims.actions.Index">
<result name="success">/jsp/index.jsp</result>
<result name="redirect" type="redirect">${redirectUrl}</result>
</action>
</package>
Index.java
package com.agchem.mims.actions;
import com.opensymphony.xwork2.ActionSupport;
public class Index extends ActionSupport {
private static final long serialVersionUID = 1475579903320095412L;
@Override
public String execute() throws Exception {
return SUCCESS;
}
}
index.jsp
<?xml version="1.0" encoding="utf-8"?>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>AGCHEM MIMS</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="keywords" content="struts2,jquery, hibernate, plugin,showcase, grid" />
<meta http-equiv="description" content="Project Maintenance" />
<link href="../styles/main.css" rel="stylesheet" type="text/css" />
<link href="../styles/menu.css" rel="stylesheet" type="text/css" />
<sj:head
loadAtOnce="true"
compressed="false"
jquerytheme="mims"
customBasepath="../themes"
loadFromGoogle="false"
debug="true"
/>
<script type="text/javascript" src="../js/menu.js"></script>
</head>
<body>
<s:url id="adm201" action="ADM201"/>
<s:url id="adm210" action="ADM210"/>
<s:url id="adm301" action="ADM301"/>
<s:url id="adm310" action="ADM310"/>
<div id="menu">
<ul class="menu" style="width: 765px">
<li>
<sj:a href="../general/main_admin.html" targets="main">Home</sj:a>
</li>
<li class="current">
<sj:a href="#" class="parent">Project</sj:a>
<div>
<ul>
<li><sj:a href="%{adm201}" class="current" targets="main">Create New Project</sj:a></li>
<li><sj:a href="%{adm210}" targets="main">Search Projects</sj:a></li>
</ul>
</div>
</li>
<li>
<sj:a href="#" class="parent">User</sj:a>
<div>
<ul>
<li><sj:a href="%{adm301}" targets="main">Create New User</sj:a></li>
<li><sj:a href="%{adm310}" targets="main">Search Users</sj:a></li>
</ul>
</div>
</li>
</ul>
</div>
<sj:div id="main" href="%{adm201}">
<img id="indicator" src="../images/indicator.gif" alt="Loading..."/>
</sj:div>
</body>
</html>
希望有人可以解释并帮助我解决我的问题。多谢!
问候,
亲爱的 =)
I'm currently creating a web application using the jquery+struts plugin. It also uses hibernate. I have two web pages already, the other one works perfectly fine but when I created another one, it threw an error saying that the action cannot be found. The error is:
ERROR (org.apache.struts2.dispatcher.Dispatcher:38) - Could not find action or result
/mims_agchem/index.action
No result defined for action com.agchem.mims.actions.Index and result success
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:375)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
These are my codes:
struts.xml
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="true" />
<package name="admin" namespace="/admin" extends="hibernate-default,json-default,struts-default">
<interceptors>
<interceptor-stack name="showcaseStack">
<interceptor-ref name="defaultStackHibernate"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="showcaseStack"/>
<action name="*" class="com.agchem.mims.actions.admin.{1}">
<result>/jsp/admin/{1}.jsp</result>
<result name="redirect" type="redirect">${redirectUrl}</result>
</action>
</package>
<package name="general" namespace="/" extends="hibernate-default,json-default,struts-default">
<interceptors>
<interceptor-stack name="showcaseStack">
<interceptor-ref name="defaultStackHibernate"/>
</interceptor-stack>
</interceptors>
<action name="index" class="com.agchem.mims.actions.Index">
<result name="success">/jsp/index.jsp</result>
<result name="redirect" type="redirect">${redirectUrl}</result>
</action>
</package>
Index.java
package com.agchem.mims.actions;
import com.opensymphony.xwork2.ActionSupport;
public class Index extends ActionSupport {
private static final long serialVersionUID = 1475579903320095412L;
@Override
public String execute() throws Exception {
return SUCCESS;
}
}
index.jsp
<?xml version="1.0" encoding="utf-8"?>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>AGCHEM MIMS</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="keywords" content="struts2,jquery, hibernate, plugin,showcase, grid" />
<meta http-equiv="description" content="Project Maintenance" />
<link href="../styles/main.css" rel="stylesheet" type="text/css" />
<link href="../styles/menu.css" rel="stylesheet" type="text/css" />
<sj:head
loadAtOnce="true"
compressed="false"
jquerytheme="mims"
customBasepath="../themes"
loadFromGoogle="false"
debug="true"
/>
<script type="text/javascript" src="../js/menu.js"></script>
</head>
<body>
<s:url id="adm201" action="ADM201"/>
<s:url id="adm210" action="ADM210"/>
<s:url id="adm301" action="ADM301"/>
<s:url id="adm310" action="ADM310"/>
<div id="menu">
<ul class="menu" style="width: 765px">
<li>
<sj:a href="../general/main_admin.html" targets="main">Home</sj:a>
</li>
<li class="current">
<sj:a href="#" class="parent">Project</sj:a>
<div>
<ul>
<li><sj:a href="%{adm201}" class="current" targets="main">Create New Project</sj:a></li>
<li><sj:a href="%{adm210}" targets="main">Search Projects</sj:a></li>
</ul>
</div>
</li>
<li>
<sj:a href="#" class="parent">User</sj:a>
<div>
<ul>
<li><sj:a href="%{adm301}" targets="main">Create New User</sj:a></li>
<li><sj:a href="%{adm310}" targets="main">Search Users</sj:a></li>
</ul>
</div>
</li>
</ul>
</div>
<sj:div id="main" href="%{adm201}">
<img id="indicator" src="../images/indicator.gif" alt="Loading..."/>
</sj:div>
</body>
</html>
Hope someone could explain and help me on my problem. Thanks a lot!
Regards,
Honey =)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
另一个页面已经可以工作了。只需在服务器上进行一些刷新和重新启动,该页面就可以正常工作。 :) 虽然很奇怪..:)
The other page already worked. With just some refresh and restarts on the server, the page just worked fine. :) Weird though.. :)