Struts 2 under IntelliJ IDEA 8.0M1
Colocado por Gustavo Felisberto em Ciência/Tecnologia, Gentoo, Gentoo-dev, Geral, tags: intellij idea, java, struts 2If you like IDEA and use Struts 2 you can be happy to know that 8.0 release comes with a new Struts 2 plugin. There is a small tutorial on how to use it but it has some errors.
First the Action class should extend ActionSupport hand have proper setter methods:
package hello; import com.opensymphony.xwork2.ActionSupport; public class HelloWorld extends ActionSupport { private String username; private String message; public String getMessage(){ return message; } public String execute(){ message = "Hello, " + username + "."; return SUCCESS; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } } |
Second the JSP file can have a proper action:
< %@ page contentType="text/html;charset=UTF-8" language="java" %> < %@ taglib prefix="s" uri="/struts-tags" %> <html> <head><title>Simple jsp page</title></head> <body> Struts 2 Message: <s :property value="message" default="Guest." /> <s :form method="GET" action="HelloWorld"> Enter your name:<s :textfield name="username" /> <s :submit value="Submit" /> </s> </body> </html> |
And finally struts.xml can have the Action declared without the ugly unRESTFUL .action:
< ?xml version="1.0" encoding="UTF-8"?> < !DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <package name="/" extends="struts-default"> <action name="HelloWorld" class="hello.HelloWorld"> <result name="success">/index.jsp</result> </action> </package> </struts> |
I really like IDEA when it comes to Java codding, and I can live with the quirks of the Struts 2 support. But one thing that makes me steam is the fact that I have to un-deploy and deploy the application for each change I make. That steals me hours every week.
Tópicos (RSS)