zoukankan      html  css  js  c++  java
  • struts2入门案例

    dl.jsp;

    <center>
      <h1>用户登录</h1>
      <hr>
    
      <form action="<%=path %>/yz.action" method="post">
    
       用户名<input type="text" name="name">
        密码<input type="password" name="password"> 
        <input type="submit" value="登录">
      </form>
     </center>

    action; 

     private String name;
     private String password;
     private String tip;
     public String getTip() {
      return tip;
     }
    
     public void setTip(String tip) {
      this.tip = tip;
     }
    
     public String getName() {
      return name;
     }
    
     public void setName(String name) {
      this.name = name;
     }
    
     public String getPassword() {
      return password;
     }
    
     public void setPassword(String password) {
      this.password = password;
     }
    
     public String execute() throws Exception {
      // TODO Auto-generated method stub
      System.out.println(name+"/"+password);
      if (name != null && "ab".equals(password)) {
       return "ok";
      }
      this.setTip("密码错误");
      return "no";
    
     }

    struts.xml;

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
    <struts>
    
     <package name="denglu" namespace="/" extends="struts-default">
      <action name="yz" class="com.st.action.YzAction">
       <result name="one">/WEB-INFhy.jsp</result>
       <result name="two">/WEB-INFdl.jsp</result>
      </action>
     
     </package> 
     
    </struts>    
    View Code
  • 相关阅读:
    立一个flag。
    详解 fcntl 记录上锁。
    [转] 虚拟机中生成与物理机的共享文档。
    Shell实现1.0
    深剖malloc、new
    由命名管道的实现联想到 read 和 fread 的区别。
    僵尸进程与孤儿进程。
    Vim引申以及Linux下彩色进度条实现
    各大排序八方齐聚!
    Docker三剑客:Compose、Machine和Swarm
  • 原文地址:https://www.cnblogs.com/laohan110/p/3524980.html
Copyright © 2011-2022 走看看