1
我試圖在頁面上點擊按鈕來顯示條形圖,它是test.jsp
。我能夠顯示圖表,但它在我的test.jsp
所在的同一個瀏覽器中作爲圖像打開。我想在新窗口中顯示它,我該怎麼做。我使用Struts2的和JFreeChart的:在不同的窗口中顯示條形圖
以下是我的動作:
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>
是JSP:
<%@ 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>
你的行爲如何被調用?使用jquery/js或jsp?你能粘貼代碼嗎? – SMA 2014-11-22 13:43:17
Hi Almas,Action從test.jsp調用如下:
– 2014-11-22 13:50:28將您的s:form更改爲form像這樣