首页 > 其他 > 详细

第一个分派struts2实例

时间:2014-01-18 18:34:31      阅读:370      评论:0      收藏:0      [点我收藏+]

dl页面;

  

bubuko.com,布布扣
<h1>用户登录</h1>
  <hr>

  <form action="<%=path %>/yz!login.action" method="post">

   用户名<input type="text" name="name">
    密码<input type="password" name="password"> 
    <input type="submit" value="登录">
  </form>


hy页面;

 <a href="<%=path %>/yz!reglster.action">退出</a>

 
View Code

 

 

Action ;

 

bubuko.com,布布扣
package com.st.action;

import com.opensymphony.xwork2.ActionSupport;

public class YzAction extends ActionSupport {

 public String login() throws Exception {
  System.out.println("login");
  return "loginok";

 }
 public String reglster() throws Exception {
  System.out.println("reglster");
  return "reglsterok";

 }


}
View Code

 

 

struts.xml;

bubuko.com,布布扣
<?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="denlu" namespace="/" extends="struts-default">
  <action name="yz" class="com.st.action.YzAction">
   <result name="loginok">/WEB-INF\hy.jsp</result>
   <result name="reglsterok">/WEB-INF\dl.jsp</result>
  </action>
 
 </package> 
 
</struts>    
View Code

第一个分派struts2实例

原文:http://www.cnblogs.com/laohan110/p/3524978.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!