读书人

Struts2-动态结果跳转

发布时间: 2012-09-21 15:47:26 作者: rapoo

Struts2----动态结果跳转

struts.xml

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE struts PUBLIC    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"    "http://struts.apache.org/dtds/struts-2.0.dtd"><struts><constant name="struts.devMode" value="true"></constant><package name="user" namespace="/user" extends="struts-default"><action name="user" name="code">package com.pegasus.web;import com.opensymphony.xwork2.ActionSupport;public class UserAction extends ActionSupport {private int type;private String r;public int getType() {return type;}public void setType(int type) {this.type = type;}public String getR() {return r;}public void setR(String r) {this.r = r;}public String execute() {System.out.println("type:" + type);//在这里定义要跳转的页面的地址if (type == 1)r = "/user_success.jsp";else if (type == 2)r = "/user_error.jsp";return "success";}}
?

?

?

?

?

读书人网 >软件架构设计

热点推荐