8

No definite results and success

 2 years ago
source link: https://www.codesd.com/item/no-definite-results-and-success.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

No definite results and success

advertisements

I'm new to struts 2 and I keep getting this error message 'No result defined for action com.jjpeople.action.HelloAction and result success' while I think I have properly refrenced it.What might be the problem?

struts.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>

    <constant name="struts.devMode" value="false" />
    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <package name="tutiworks" extends="struts-default">
        <action name="index">
            <result>/index.jsp</result>
        </action>
        <action name="hello" class="com.jjpeople.action.HelloAction" method="execute">
                <result name="success">/welcome.jsp</result>
        </action>
    </package>
</struts>

index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Basic Struts 2 Application - Welcome</title>
</head>
    <body>
        <h1>Welcome To Struts 2!</h1>
        <p><a href="<s:url action='hello'/>">Hello World</a></p>
    </body>
</html>

Action class

package com.jjpeople.action;

import com.jjpeople.model.Hello;
import com.opensymphony.xwork2.ActionSupport;

public class HelloAction extends ActionSupport
{
    private static final long serialVersionUID = 1L;
    private Hello hello;

    public String execute() throws Exception
    {
        hello = new Hello();
        return SUCCESS;
    }
    public Hello getMessage()
    {
        return hello;
    }
    public void setMessage(Hello hello)
    {
        this.hello = hello;
    }
}


In your xml file

<action name="hello" class="com.jjpeople.action.HelloAction" method="execute">                 <result name="success">/welcome.jsp</result>         </action>

result name is "success",But in your Action class you returnd "SICCESS" variable.So please check the SUCCESS variable value.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK