zoukankan      html  css  js  c++  java
  • Struts2动态结果集

    配置文件

     1 <?xml version="1.0" encoding="UTF-8" ?>
     2 <!DOCTYPE struts PUBLIC
     3     "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
     4     "http://struts.apache.org/dtds/struts-2.0.dtd">
     5 
     6 <struts>
     7     <constant name="struts.devMode" value="true" />
     8     <package name="user" namespace="/user" extends="struts-default">
     9         
    10         <action name="user" class="com.bjsxt.struts2.user.action.UserAction">
    11         <!-- 表示往值栈里面取值 在该类中r是action的属性 而r是传入的数值所以是动态结果集 -->
    12             <result>${r}</result>
    13         </action>        
    14     </package>
    15         
    16 </struts>

    UserAction详情

     1 package com.bjsxt.struts2.user.action;
     2 
     3 import com.opensymphony.xwork2.ActionSupport;
     4 
     5 public class UserAction extends ActionSupport {
     6     private int type;
     7     
     8     private String r;
     9 
    10     public String getR() {
    11         return r;
    12     }
    13 
    14     public void setR(String r) {
    15         this.r = r;
    16     }
    17 
    18     public int getType() {
    19         return type;
    20     }
    21 
    22     public void setType(int type) {
    23         this.type = type;
    24     }
    25 
    26     @Override
    27     public String execute() throws Exception {
    28         //根据传入数据动态决定跳转的jsp
    29         if(type == 1) r="/user_success.jsp";
    30         else if (type == 2) r="/user_error.jsp";
    31         return "success";
    32     }
    33 
    34 }
  • 相关阅读:
    导入导出模块
    jQuery复习
    vue记录
    angular 初探之父子组件之间传递数据
    webpack
    go语言语法记录
    dom元素的滚动(如何实现点击展开更多功能)
    正则回忆录
    Attributes 和 properties区别和联系?
    显示 隐藏DIV的技巧
  • 原文地址:https://www.cnblogs.com/elleniou/p/2728566.html
Copyright © 2011-2022 走看看