Struts2巩固笔记一
开发流程:
1.搭建开发和运行环境
Eclipse JavaEE 3.6.2
Struts 2.0包:commons-logging-1.0.4.jarfreemarker-2.3.15.jarognl-2.7.3.jarstruts2-core-2.1.8.1.jarxwork-2.1.6.jar
2.打开web.xml将其修改为以下代码:
<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"><web-app> <display-name>Struts 2.0 Hello World</display-name> <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> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list></web-app>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"><struts> <include file="struts-default.xml"/> <package name="tutorial" extends="struts-default"> <action name="HelloWorld" name="code"><%@ page contentType="text/html; charset=UTF-8" %><%@ taglib prefix="s" uri="/struts-tags" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>Say Hello</title> </head> <body> <h3>Say "Hello" to: </h3> <s:form action="HelloWorld"> Name: <s:textfield name="name" /> <s:submit /> </s:form> </body></html>