struts.xml
-----------------
<?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>
<constant name="struts.devMode" value="true" />
<package name="kites" extends="struts-default">
<action name="actionSupport" class="com.kites.ActionSupportExample">
<result>actionsupport.jsp</result>
</action>
</package>
</struts>
--------------------------------------------------------------------------------------------------------------------------
ActionSupportExample.java
-------------------------------------------
package com.kites;
import com.opensymphony.xwork2.ActionSupport;
public class ActionSupportExample extends ActionSupport {
public String execute() throws Exception {
setMessage(getText(ACTIONMESSAGE));
System.out.println("Some Action Support Messages");
return SUCCESS;
}
public static final String ACTIONMESSAGE = "ActionSupportExample.message";
private String message;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
----------------------------------------------------------------------------------------------------------------------------
actionsupport.jsp
--------------------------
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title><s:text name="ActionSupportExample.message"/></title>
</head>
<body>
<h2><s:property value="message"/></h2>
<a href="#">Back to Index page</a>
</body>
</html
-------------------------------------------------------------------------------------------------------------------------
web.xml
--------------
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>Struts 2</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
----------------------------------------------------------------------------------------
-----------------
<?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>
<constant name="struts.devMode" value="true" />
<package name="kites" extends="struts-default">
<action name="actionSupport" class="com.kites.ActionSupportExample">
<result>actionsupport.jsp</result>
</action>
</package>
</struts>
--------------------------------------------------------------------------------------------------------------------------
ActionSupportExample.java
-------------------------------------------
package com.kites;
import com.opensymphony.xwork2.ActionSupport;
public class ActionSupportExample extends ActionSupport {
public String execute() throws Exception {
setMessage(getText(ACTIONMESSAGE));
System.out.println("Some Action Support Messages");
return SUCCESS;
}
public static final String ACTIONMESSAGE = "ActionSupportExample.message";
private String message;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
----------------------------------------------------------------------------------------------------------------------------
actionsupport.jsp
--------------------------
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title><s:text name="ActionSupportExample.message"/></title>
</head>
<body>
<h2><s:property value="message"/></h2>
<a href="#">Back to Index page</a>
</body>
</html
-------------------------------------------------------------------------------------------------------------------------
web.xml
--------------
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>Struts 2</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
----------------------------------------------------------------------------------------
No comments:
Post a Comment