Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><br> The way you have your welcome-file in web.xml it would only display "The Error message is". </p> <p>You need to go straight to the action, so that you get an initial value. You need an additional index.html like this one: </p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Dummy Project&lt;/title&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;META HTTP-EQUIV="Refresh" CONTENT="0;URL=hello.action"&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;Project is Loading ...&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Index.html should be your welcome-file in your web.xml. Your struts.xml is here:</p> <pre><code>&lt;struts&gt; &lt;constant name="struts.devMode" value="true"/&gt; &lt;include file="struts-default.xml"/&gt; &lt;package name="foo" extends="struts-default"&gt; &lt;action name="hello" class="com.example.action.HelloWorld"&gt; &lt;result name="success"&gt;/hello-world.jsp&lt;/result&gt; &lt;/action&gt; &lt;/package&gt; &lt;/struts&gt; </code></pre> <p>"hello" is your action. Only a "success" result is necessary here. After the action runs, you will be redirected to your hello-world.jsp:</p> <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt; &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; &lt;%@taglib uri="/struts-tags" prefix="s" %&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;title&gt;JSP Page&lt;/title&gt; &lt;/head&gt; &lt;body&gt; The Error message is ${message} &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Here is your HelloWorld.java. Execute() returns only SUCCESS. This should be sufficient. </p> <pre><code>package com.example.action; import com.opensymphony.xwork2.ActionSupport; public class HelloWorld extends ActionSupport { private String message; public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public HelloWorld() { } @Override public String execute() { if (System.currentTimeMillis() % 2 == 0) message = "It's 0"; else message = "It's 1"; return SUCCESS; } } </code></pre> <p>You can certainly do the same with annotations. It should be easy to make this work. I use this <a href="http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=23467" rel="nofollow">NetBeans Struts2 Support</a> plugin. Enjoy...</p> <p>Costis </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload