Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This question: <a href="https://stackoverflow.com/questions/1619758/is-struts2-still-a-good-choice-of-web-framework-for-new-projects">https://stackoverflow.com/questions/1619758/is-struts2-still-a-good-choice-of-web-framework-for-new-projects</a> is about one user debating to use struts2 which may be pertinent to others making the decision. </p> <p>Following is an example of Struts2, although struts has it's own tags which would make the follwing more maintainable I decided to go with plain html where possible to make it clearer how it automagically moves values to the action and then to the view.</p> <p>/WEB-INF/content/hello.jsp</p> <pre><code>&lt;%@taglib prefix="s" uri="/struts-tags"%&gt; &lt;html&gt; &lt;body&gt; &lt;form action="hello-world"&gt; Enter Your Name: &lt;input type="text" name="name"/&gt; &lt;input type="submit" value="Submit" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>When the above is submitted "name" is set on the following action (If I had encapsulated name with get/set the example would work exactly the same but be longer)</p> <pre><code>package struts2; import com.opensymphony.xwork2.ActionSupport; public class HelloWorldAction extends ActionSupport{ public String name; } </code></pre> <p>then this page is rendered /WEB-INF/content/hello-world.jsp</p> <pre><code>&lt;%@taglib prefix="s" uri="/struts-tags"%&gt; &lt;html&gt; &lt;body&gt; &lt;h1&gt;Hello World &lt;s:property value="name"/&gt;&lt;/h1&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This is an example of Struts2 with conventions (one extra jar on the class path), no other configuration required.</p>
 

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