---
title: "动态结果集DynamicResult"
author: "netxdiy"
date: "2011-03-19T16:04:45Z"
tags: ["Apache", "JSP", "Struts", "XHTML", "XML"]
categories: ["企业架构"]
slug: "dynamicresult"
draft: false
lastmod: "2011-03-21T16:15:57Z"
id: 967627
url: "https://netxdiy.iteye.com/blog/967627"
---

struts.xml ${r} UserAction.java package com.bjsxt.struts2.user.action; import com.opensymphony.xwork2.ActionSupport; public class UserAction extends ActionSupport { private int type; private String r; public String getR() { return r; } public void setR(String r) { this.r = r; } public int getType() { return type; } public void setType(int type) { this.type = type; } @Override public String execute() throws Exception { if(type == 1) r="/user\_success.jsp"; else if (type == 2) r="/user\_error.jsp"; return "success"; } } index.jsp &lt;%@ page language="java" contentType="text/html; charset=GB18030" pageEncoding="GB18030"%&gt; &lt;% String context = request.getContextPath(); %&gt; Insert title here 动态结果 一定不要忘了为动态结果的保存值设置set get方法

1. [返回success](user/user?type=1)
2. [返回error](user/user?type=2)