1
我有test.jsp
它有兩個按鈕。點擊顯示圖表按鈕,它應該在表格標籤中使用target=_blank
在新頁面上打開圖表。但問題是我不希望這種行爲點擊顯示數據按鈕。單擊此按鈕時,我想要顯示僅在同一頁面上獲取的數據,但當前爲此按鈕以及打開一個新窗口。在Struts 2的同一頁上點擊兩個按鈕時的不同行爲
我的代碼是:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Data</title>
<s:head theme="ajax" debug="true"/>
</head>
<body bgcolor="white">
<s:form validate="true" target="_blank">
<table>
//Mapping of data from database
</table>
<s:submit id="submit" value="Display Chart" align="left" action="testAction"/>
<s:submit value="Display Data" align="left" action="displayDataAction"/>`
</s:form>
</body>
</html>
public class TestAction extends ActionSupport{
public String execute() throws Exception {
//code to populate DataSet
chart = ChartFactory.createBarChart(
"Bar Chart", //Chart title
"", //Domain axis label
"MARKETS", //Range axis label
dataSet, //Chart Data
PlotOrientation.VERTICAL, // orientation
true, // include legend?
true, // include tooltips?
false // include URLs?
);
chart.setBorderVisible(true);
return SUCCESS;
}
}
struts.xml
:
<action name="testAction"
class="testAction"
method="execute">
<result name="success" type="chart">
<param name="value">chart</param>
<param name="type">jpeg</param>
<param name="width">600</param>
<param name="height">400</param>
</result>
</action>
<action name="displayDataAction"
class="testAction"
method="getData">
<result name="success">test.jsp</result>
</action>
我試過了,但是我的動作並沒有被調用。任何人都可以提示我做錯了什麼: