Created
October 29, 2016 13:07
-
-
Save afsinka/08b2e9887c28c70712a5ad04b421ca16 to your computer and use it in GitHub Desktop.
Struts 2 Hello World
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" | |
pageEncoding="ISO-8859-1"%> | |
<%@ taglib prefix="s" uri="/struts-tags"%> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> | |
<title>Index</title> | |
</head> | |
<body> | |
<h1>Struts 2 - Index</h1> | |
<s:form action="Welcome"> | |
<s:textfield name="name" label="name" /> | |
<s:submit /> | |
</s:form> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>Struts2_HelloWorld</groupId> | |
<artifactId>Struts2_HelloWorld</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<packaging>war</packaging> | |
<dependencies> | |
<dependency> | |
<groupId>org.apache.struts</groupId> | |
<artifactId>struts2-core</artifactId> | |
<version>2.3.1.2</version> | |
</dependency> | |
</dependencies> | |
<build> | |
<plugins> | |
<plugin> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>3.3</version> | |
<configuration> | |
<source>1.8</source> | |
<target>1.8</target> | |
</configuration> | |
</plugin> | |
<plugin> | |
<artifactId>maven-war-plugin</artifactId> | |
<version>2.6</version> | |
<configuration> | |
<warSourceDirectory>webapp</warSourceDirectory> | |
<failOnMissingWebXml>false</failOnMissingWebXml> | |
</configuration> | |
</plugin> | |
<plugin> | |
<groupId>org.eclipse.jetty</groupId> | |
<artifactId>jetty-maven-plugin</artifactId> | |
<version>9.2.11.v20150529</version> | |
<configuration> | |
<httpConnector> | |
<port>9091</port> | |
</httpConnector> | |
</configuration> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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="com.afsinka" namespace="/Struts2-Test" extends="struts-default"> | |
<action name="Index"> | |
<result>/index.jsp</result> | |
</action> | |
<action name="Welcome" class="com.afsinka.WelcomeAction"> | |
<result name="true">/welcome_user.jsp</result> | |
</action> | |
</package> | |
</struts> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns="http://xmlns.jcp.org/xml/ns/javaee" | |
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" | |
id="WebApp_ID" version="3.1"> | |
<display-name>Struts_HelloWorld</display-name> | |
<filter> | |
<filter-name>struts2</filter-name> | |
<filter-class> | |
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter | |
</filter-class> | |
</filter> | |
<filter-mapping> | |
<filter-name>struts2</filter-name> | |
<url-pattern>/*</url-pattern> | |
</filter-mapping> | |
</web-app> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" | |
pageEncoding="ISO-8859-1"%> | |
<%@ taglib prefix="s" uri="/struts-tags"%> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> | |
<title>Welcome User</title> | |
</head> | |
<body> | |
<h1>Struts 2 - Welcome User</h1> | |
<h2> | |
Hello | |
<s:property value="name" /> | |
! | |
</h2> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.afsinka; | |
public class WelcomeAction { | |
private String name; | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public String execute() { | |
System.out.println("Executed for: " + name); | |
return Boolean.TRUE.toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment