HTTP状态404-未为操作结果登录定义结果 [英] HTTP Status 404 - No result defined for action result login
问题描述
我正在尝试开发一个Struts2应用程序,该应用程序在单击超链接时会调用一个动作,该超链接使用Struts动作映射将用户定向到Category.jsp.我收到以下错误:
I'm trying to develop a Struts2 app where an action is invoked upon clicking a hyperlink which directs the user to a Classification.jsp using Struts action mapping. I'm getting the following error:
HTTP Status 404 - No result defined for action com.tdl.cempia.healthcare.action.ClassificationAction and result login
JSP:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<form action="addClassification">
<tabel>
<tr>
<td><input type="text" name="label"/></td>
<td><input type="submit" value="Add"/></td>
</tr>
</tabel>
<form>
操作:
<action name="addClassification" class="com.tdl.cempia.healthcare.action.ClassificationAction" method="addClassification">
<interceptor-ref name="loginStack" />
<result name="input">Overview/Classification.jsp</result>
<result name="success">Overview/Classification.jsp</result>
<result name="error">AdminLogin.jsp</result>
</action>
班级:
import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.struts2.interceptor.SessionAware;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import com.tdl.cempia.healthcare.service.ClassificationService;
public class ClassificationAction extends ActionSupport
{
private static final Logger logger = Logger.getLogger(ClassificationAction.class);
ClassificationService cService;
private int id;
private String label;
private String level;
private int perentID;
@SuppressWarnings("unchecked")
public String addClassification(int id,String label,String level,int pID)
{
System.out.println(id);
System.out.println(label);
System.out.println(level);
System.out.println(pID);
return Action.SUCCESS;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getLevel() {
return level;
}
public void setLevel(String level) {
this.level = level;
}
public int getPerentID() {
return perentID;
}
public void setPerentID(int perentID) {
this.perentID = perentID;
}
}
推荐答案
您正在使用自定义拦截器堆栈,该堆栈将login
结果代码返回到操作调用,这将阻止该代码执行操作.但是正在拦截的动作未在动作配置中配置此结果.
You are using custom interceptor stack that returns login
result code to the action invocation and this stops it from executing the action. But the action that is intercepting doesn't have this result configured in the action config.
您可以使用<global-results>
标记全局配置结果,例如此答案
You can config result globally using <global-results>
tag like in this answer
<global-results>
<result name="login" type="redirect">${target}</result>
</global-results>
这篇关于HTTP状态404-未为操作结果登录定义结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!