第一个Struts程序(Helloworld)
2016-10-29 08:58
295 查看
1:index.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML >
<html>
<head>
<title>HelloWorld</title>
</head>
<body>
this is my first Struts2 Demo!
</body>
</html>
2: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" 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>Struts2Env</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>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
3:struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="default" namespace="/" extends="struts-default">
<action name="hello" class="cn.com.mooc/MyAction">
<result name="success">/hello.jsp</result>
</action>
</package>
</struts>
4:Action(控制器)
package cn.com.mooc;
import com.opensymphony.xwork2.ActionSupport;
public class MyAction extends ActionSupport {
private static final long serialVersionUID = 1L;
@Override
public String execute()throws Exception{
return SUCCESS;
}
}
相关文章推荐
- 如何学习struts并写第一个程序HelloWorld
- 终于调试出第一个Struts程序!!!
- EJB3.0学习(二)第一个程序HelloWorld
- Struts1.x系列教程(1):用MyEclipse开发第一个Struts程序
- J2ME入门程序--第一个HELLOWORLD手机程序
- 编译你的第一个Sac程序——HelloWorld!
- 我的第一个ASP.NET程序——HelloWorld
- 用MyEclipse开发第一个Struts程序
- Struts1.x系列教程(1):用MyEclipse开发第一个Struts程序(二)
- Struts1.x系列教程(1):用MyEclipse开发第一个Struts程序(一)
- GNUstep Gorm第一个helloworld视窗程序
- Struts 2.0初体验--参照Tutorials来写第一个Struts 2.0程序
- [C#]第一个程序——HelloWorld
- 第一个struts程序
- Struts1.x系列教程(1):用MyEclipse开发第一个Struts程序
- 第一个JAVA程序 helloworld
- 开发第一个Struts程序遇到两个问题
- 从struts 1.x升级到 struts 2(一) 第一个程序
- Struts1.x系列教程(1):用MyEclipse开发第一个Struts程序
- The NOTE of learning ASP.NET [7] 使用记事本与CSC开发第一个.NET程序HelloWorld