Powww queria saber se alguem ai conhece da existencia de algum tutorial do struts2!!??
Abraço!!
XD
Powww queria saber se alguem ai conhece da existencia de algum tutorial do struts2!!??
Abraço!!
XD
primeiro, baixa esse zip, e pega os jars do projeto struts.blanck-app
cria um jsp HelloWorld.jsp<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<h2><s:property value="message" /></h2>
</body>
</html>
package tutorial;
import com.opensymphony.xwork2.ActionSupport;
public class HelloWorld extends ActionSupport {
public static final String MESSAGE = "Struts is up and running ...";
public String execute() throws Exception {
setMessage(MESSAGE);
return SUCCESS;
}
private String message;
public void setMessage(String message){
this.message = message;
}
public String getMessage() {
return message;
}
}
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="tutorial" extends="struts-default">
<action name="HelloWorld" class="tutorial.HelloWorld">
<result>/HelloWorld.jsp</result>
</action>
<!-- Add your actions here -->
</package>
</struts>
no seu web.xml coloca esse filtro
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>applicationSessionFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Seu helloworld com struts2 deve atender em http://localhost:8080/nomedasuaaplicacaoaqui/HelloWorld.action
fonte: http://struts.apache.org/2.0.14/docs/hello-world.html