***book.jsp***
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>   
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Logon</title>
</head>
<body>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Logon</title>
</head>
<body>
<html:form action="/user/bookAction" focus="userId"><br>
 BookId:<html:text property="bookId" maxlength="10"/><br>
 
 BookName:<html:text property="bookName" maxlength="20"/><br>
 
 <html:submit>logon</html:submit>
</html:form>
</body>
</html>   
</html:form>
</body>
</html>
***BookForm.java***
package cn.com.chengang.sms.user;
import org.apache.struts.action.ActionForm;
public class BookForm extends ActionForm
{
 private String bookId;
 private String bookName;
 
 public String getBookId()
 {
  return this.bookId;
 }
 public void setBookId(String bookId)
 {
  this.bookId=bookId;
 }
 
 public String getBookName()
 {
  return this.bookName;
 }
 public void setBookName(String bookName)
 {
  this.bookName=bookName;
 }
}                      
{
}
***BookAction.java***
package cn.com.chengang.sms.user;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import javax.servlet.http.*;
public class BookAction extends Action
{
 public ActionForward execute(
   ActionMapping mapping,
   ActionForm form,
   HttpServletRequest request,
   HttpServletResponse response
   ) throws Exception
 {
  BookForm bf=(BookForm)form;
  String bookId=bf.getBookId();
  String bookName=bf.getBookName();
  
  return mapping.findForward("booksuccess");
 }
}
                           
{
}
***struts-config.xml ***
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
          "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">                  
<struts-config>
</struts-config>
***web.xml***
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
  "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">  
<web-app>
  <display-name>SMS Application</display-name>
 
  <!-- Standard Action Servlet Configuration (with debugging) -->
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
      <param-name>debug</param-name>
      <param-value>2</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>2</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
  </servlet>                                                             
</web-app>
 
                    
                     
                    
                 
                    
                 

 
         
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号