日期:2014-05-18 浏览次数:20676 次
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-
class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilt
er</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
<?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="struts2" extends="struts-default">
<action name="book"
class="com.softeem.struts.actions.BookAction">
<result type="redirect">/index.jsp</result>
</action>
</package>
</struts>
<body>
<a href="book!addBook.action">添加图书信息</a><br />
<a href="book!delBook.action">删除图书信息</a><br />
<a href="book!updateBook.action">修改图书信息</a><br />
<a href="book!readBook.action">查询图书信息</a><br />
</body>
package com.softeem.struts.actions;
import com.opensymphony.xwork2.ActionSupport;
public class BookAction extends ActionSupport {
public String addBook() {
System.out.println("添加图书成功!");
return SUCCESS;
}
public String delBook() {
System.out.println("删除图书成功!");
return SUCCESS;
}
public String updateBook() {
System.out.println("修改图书成功!");
return SUCCESS;
}
public String readBook() {
System.out.println("查询图书成功!");
return SUCCESS;
}
}