Chinaunix首页 | 论坛 | 博客
  • 博客访问: 182029
  • 博文数量: 88
  • 博客积分: 2000
  • 博客等级: 大尉
  • 技术积分: 914
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-10 13:41
文章分类

全部博文(88)

文章存档

2010年(2)

2009年(35)

2008年(51)

我的朋友

分类: WINDOWS

2009-01-10 18:07:26

1.form
package com.mycompany.form;
import org.apache.struts.action.ActionForm;
public class loginForm extends ActionForm {

 private static final long serialVersionUID = 1L;
 private String  username ;
   
    public String  getUsername ()
    {
     return username;
    }
    public void  setUsername (String un)
    {
     this.username = un;
    }
}
----------------------------------------------
2.action:
package com.mycompany.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.mycompany.form.loginForm;
public class loginAction extends Action {
 public ActionForward execute(
   ActionMapping mapping,
   ActionForm form,
   HttpServletRequest request,
   HttpServletResponse response)
   throws Exception {
           
  loginForm  lf = (loginForm) form;
  String sname = lf.getUsername();
  System.out.println(sname);
  return mapping.findForward("success");
  
  
 }
}
-----------------------------------------------------------------
3.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


 
   
   
    My JSP 'index.jsp' starting page
 
 
    
 
 
 
 
 
 
    This is my JSP page.

   

  •     <%=path%>
        

  •      

  •     <%=basePath%>
        
  •    
       
       
  • 测试
          
      //写.do
            姓名
                
          
          
        
        

  •  

    -----------------------------------
    4.web.xml


     
        action
        org.apache.struts.action.ActionServlet
       
          config
          /WEB-INF/struts-config.xml
       

       
          debug
          3
       

       
          detail
          3
       

        0
     

     
        action
        *.do
     

     
        pages/login.jsp
     

    ---------------------------
    5.struts-config.xml


     
     
           
     
     
     
     
                     name ="loginForm"
                 type="com.mycompany.action.loginAction"
                 scope="request">
                           
          
     

     
    阅读(607) | 评论(0) | 转发(0) |
    0

    上一篇:tuxedo jrepository

    下一篇:没有form的动态action

    给主人留下些什么吧!~~