带有JSF,Servlet和CDI的DynamicReports和JasperReports

在此示例中,我将展示如何将DynamicReport和JasperReports与Servlet和CDI集成。

工具:

  • TIBCO Jaspersoft Studio-6.0.4。最终版
  • Eclipse Luna服务版本2(4.4.2)。
  • WildFly 8.x应用程序服务器。

这是Eclipse上项目层次结构的屏幕截图。

2-DynamicReportsWithJSFServletsAndCDI

  1. pom.xml文件包含Servlets + JSF + CDI + DynamicReports所需的依赖项。
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.ithinkisink</groupId><artifactId>DynamicReportsWithJSFServletsAndCDI</artifactId><packaging>war</packaging><version>0.0.1-SNAPSHOT</version><name>DynamicReportsWithJSFServletsAndCDI Maven Webapp</name><dependencies><dependency><groupId>javax.inject</groupId><artifactId>javax.inject</artifactId><version>1</version><scope>provided</scope></dependency><dependency><groupId>javax.faces</groupId><artifactId>jsf-api</artifactId><version>2.1</version><scope>provided</scope></dependency><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>3.1.0</version><scope>provided</scope></dependency><dependency><groupId>javax.enterprise</groupId><artifactId>cdi-api</artifactId><version>1.0</version><scope>provided</scope></dependency><dependency><groupId>net.sourceforge.dynamicreports</groupId><artifactId>dynamicreports-core</artifactId><version>4.0.0</version></dependency></dependencies><build><finalName>DynamicReportsWithJSFServletsAndCDI</finalName><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.1</version><configuration><source>1.7</source><target>1.7</target></configuration></plugin></plugins></build>
    </project>
  2. 使用TIBCO Jaspersoft Studio创建一个简单的JRXML模板,其中包含一个图像,该图像随后将作为参数从DynamicReportsManagedBean动态传递到DynamicReports。
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- Created with Jaspersoft Studio version 6.0.4.final using JasperReports Library version 6.0.4  -->
    <!-- 2015-12-04T17:15:43 -->
    <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Invoice" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="4eedbb89-b4f6-4469-9ab6-f642a1688cf7"><property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/><style name="Title" forecolor="#FFFFFF" fontName="Times New Roman" fontSize="50" isBold="false" pdfFontName="Times-Bold"/><style name="SubTitle" forecolor="#CCCCCC" fontName="Times New Roman" fontSize="18" isBold="false" pdfFontName="Times-Roman"/><style name="Column header" forecolor="#666666" fontName="Times New Roman" fontSize="14" isBold="true"/><style name="Detail" mode="Transparent" fontName="Times New Roman"/><style name="Row" mode="Transparent" fontName="Times New Roman" pdfFontName="Times-Roman"><conditionalStyle><conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression><style mode="Opaque" backcolor="#EEEFF0"/></conditionalStyle></style><style name="Table"><box><pen lineWidth="1.0" lineColor="#000000"/><topPen lineWidth="1.0" lineColor="#000000"/><leftPen lineWidth="1.0" lineColor="#000000"/><bottomPen lineWidth="1.0" lineColor="#000000"/><rightPen lineWidth="1.0" lineColor="#000000"/></box></style><style name="Table_TH" mode="Opaque" backcolor="#FFFFFF"><box><pen lineWidth="0.5" lineColor="#000000"/><topPen lineWidth="0.5" lineColor="#000000"/><leftPen lineWidth="0.5" lineColor="#000000"/><bottomPen lineWidth="0.5" lineColor="#000000"/><rightPen lineWidth="0.5" lineColor="#000000"/></box></style><style name="Table_CH" mode="Opaque" backcolor="#CACED0"><box><pen lineWidth="0.5" lineColor="#000000"/><topPen lineWidth="0.5" lineColor="#000000"/><leftPen lineWidth="0.5" lineColor="#000000"/><bottomPen lineWidth="0.5" lineColor="#000000"/><rightPen lineWidth="0.5" lineColor="#000000"/></box></style><style name="Table_TD" mode="Opaque" backcolor="#FFFFFF"><box><pen lineWidth="0.5" lineColor="#000000"/><topPen lineWidth="0.5" lineColor="#000000"/><leftPen lineWidth="0.5" lineColor="#000000"/><bottomPen lineWidth="0.5" lineColor="#000000"/><rightPen lineWidth="0.5" lineColor="#000000"/></box><conditionalStyle><conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression><style backcolor="#D8D8D8"/></conditionalStyle></style><subDataset name="tableDataset" uuid="f13e6d36-5148-4ecc-bbe3-3035def80980"><queryString><![CDATA[]]></queryString></subDataset><parameter name="invoiceNo" class="java.lang.String"/><parameter name="billingCompanyName" class="java.lang.String"/><parameter name="billingCompanyAddress" class="java.lang.String"/><parameter name="billingCompanyFirstState" class="java.lang.String"/><parameter name="billingCompanySecondState" class="java.lang.String"/><parameter name="shippingName" class="java.lang.String"/><parameter name="shippingAddress" class="java.lang.String"/><parameter name="shippingFirstState" class="java.lang.String"/><parameter name="shippingSecondState" class="java.lang.String"/><parameter name="IMAGE_PATH" class="java.lang.String"/><queryString language="SQL"><![CDATA[]]></queryString><field name="itemNo" class="java.lang.String"/><field name="description" class="java.lang.String"/><field name="unitCost" class="java.lang.Double"/><field name="quantity" class="java.lang.Integer"/><group name="Gruppo1"><groupExpression><![CDATA[(int)($V{REPORT_COUNT}/15)]]></groupExpression><groupHeader><band/></groupHeader><groupFooter><band><property name="local_mesure_unitheight" value="pixel"/><property name="com.jaspersoft.studio.unit.height" value="px"/></band></groupFooter></group><title><band height="196" splitType="Stretch"><staticText><reportElement x="0" y="90" width="84" height="25" uuid="57aed2b1-4f4e-40a3-a6ad-54dae8dd4c5a"><property name="local_mesure_unitheight" value="pixel"/><property name="com.jaspersoft.studio.unit.height" value="px"/></reportElement><textElement><font size="16" isBold="true"/></textElement><text><![CDATA[Bill to:]]></text></staticText><line><reportElement x="0" y="80" width="556" height="1" uuid="806ce5df-1219-4876-ae0c-ca7405b1f246"><property name="local_mesure_unitheight" value="pixel"/><property name="com.jaspersoft.studio.unit.height" value="px"/></reportElement></line><staticText><reportElement x="400" y="90" width="84" height="25" uuid="139ebe8d-25b0-411e-986c-270015400874"><property name="local_mesure_unitheight" value="pixel"/><property name="com.jaspersoft.studio.unit.height" value="px"/></reportElement><textElement><font size="16" isBold="true"/></textElement><text><![CDATA[Ship to:]]></text></staticText><staticText><reportElement x="415" y="10" width="50" height="20" uuid="0f86baff-6386-4f3f-b3fe-2388707babe8"/><box rightPadding="4"/><textElement textAlignment="Right"/><text><![CDATA[Date:]]></text></staticText><textField pattern="EEEEE dd MMMMM yyyy"><reportElement x="465" y="10" width="84" height="20" uuid="bb10dbe1-0a4f-4722-9953-c163b63cf979"/><textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression></textField><image hAlign="Center"><reportElement x="0" y="0" width="65" height="60" uuid="94883631-a913-43e2-b182-ab8d77d0181e"/><imageExpression><![CDATA[$P{IMAGE_PATH} + "/invoice_logo.png"]]></imageExpression></image><textField pattern="EEEEE dd MMMMM yyyy"><reportElement x="465" y="30" width="84" height="20" uuid="3836ce65-eca3-4cad-a6de-b1818def0a2b"/><textFieldExpression><![CDATA[$P{invoiceNo}]]></textFieldExpression></textField><staticText><reportElement x="415" y="30" width="50" height="20" uuid="0b3f9342-da78-4cfa-9fc5-2301c4749678"/><box rightPadding="4"/><textElement textAlignment="Right"/><text><![CDATA[Invoice #]]></text></staticText><staticText><reportElement x="95" y="0" width="210" height="25" uuid="e622555d-198b-4ccd-a4a1-c59c53304058"><property name="local_mesure_unitheight" value="pixel"/><property name="com.jaspersoft.studio.unit.height" value="px"/></reportElement><textElement><font size="19" isBold="true"/></textElement><text><![CDATA[I think, I sink!]]></text></staticText><staticText><reportElement x="95" y="55" width="205" height="15" uuid="b8cc42fd-b569-497d-834d-7e854040ad18"/><text><![CDATA[+20 10 000 0000]]></text></staticText><staticText><reportElement x="95" y="25" width="205" height="15" uuid="c226e44d-3bb5-4145-b0b3-903bf1d79fde"/><text><![CDATA[Sesame street]]></text></staticText><staticText><reportElement x="95" y="40" width="205" height="15" uuid="b96f7183-44f8-43ad-ba60-43d8fbf50b6e"/><text><![CDATA[Sesame city]]></text></staticText><textField><reportElement x="0" y="115" width="150" height="15" uuid="7e9e0af2-08d1-4997-b3e1-971e74b1c8ad"><property name="local_mesure_unitheight" value="pixel"/><property name="com.jaspersoft.studio.unit.height" value="px"/></reportElement><textFieldExpression><![CDATA[$P{billingCompanyName}]]></textFieldExpression></textField><textField><reportElement x="0" y="130" width="150" height="15" uuid="a0eaddab-ed2f-46fc-b9fc-d0d9747c6df3"><property name="local_mesure_unitheight" value="pixel"/><property name="com.jaspersoft.studio.unit.height" value="px"/></reportElement><textFieldExpression><![CDATA[$P{billingCompanyAddress}]]></textFieldExpression></textField><textField><reportElement x="0" y="145" width="150" height="15" uuid="f9371f1e-125e-408d-a0f0-aa0ea5adc171"><property name="local_mesure_unitheight" value="pixel"/><property name="com.jaspersoft.studio.unit.height" value="px"/></reportElement><textFieldExpression><![CDATA[$P{billingCompanyFirstState}]]></textFieldExpression></textField><textField><reportElement x="0" y="160" width="150" height="15" uuid="c14d7758-80e6-45d7-8526-797330e515d3"><property name="local_mesure_unitheight" value="pixel"/><property name="com.jaspersoft.studio.unit.height" value="px"/></reportElement><textFieldExpression><![CDATA[$P{billingCompanySecondState}]]></textFieldExpression></textField><textField><reportElement x="400" y="160" width="140" height="15" uuid="a9baefea-45b3-4826-a81e-3572507eea6d"><property name="local_mesure_unitheight" value="pixel"/><property name="com.jaspersoft.studio.unit.height" value="px"/></reportElement><textFieldExpression><![CDATA[$P{shippingSecondState}]]></textFieldExpression></textField><textField><reportElement x="400" y="145" width="140" height="15" uuid="338e1f40-9a03-4b77-aedc-568b1907628b"><property name="local_mesure_unitheight" value="pixel"/><property name="com.jaspersoft.studio.unit.height" value="px"/></reportElement><textFieldExpression><![CDATA[$P{shippingFirstState}]]></textFieldExpression></textField><textField><reportElement x="400" y="130" width="140" height="15" uuid="54e6473f-44ef-4839-8f87-29e65af72561"><property name="local_mesure_unitheight" value="pixel"/><property name="com.jaspersoft.studio.unit.height" value="px"/></reportElement><textFieldExpression><![CDATA[$P{shippingAddress}]]></textFieldExpression></textField><textField><reportElement x="400" y="115" width="140" height="15" uuid="1f093c2e-2d6f-403e-9c11-160dbaf82e6f"><property name="local_mesure_unitheight" value="pixel"/><property name="com.jaspersoft.studio.unit.height" value="px"/></reportElement><textFieldExpression><![CDATA[$P{shippingName}]]></textFieldExpression></textField></band></title><columnHeader><band height="24"><staticText><reportElement x="366" y="4" width="80" height="20" uuid="be792358-dade-4931-965d-fe4d4958b71c"/><textElement textAlignment="Center"><font size="12" isBold="false"/></textElement><text><![CDATA[Quantity]]></text></staticText><rectangle><reportElement mode="Opaque" x="10" y="2" width="531" height="20" backcolor="#C0D4EC" uuid="ce42b0b0-0d12-48c1-8020-576969255150"/><graphicElement><pen lineColor="#666666"/></graphicElement></rectangle><staticText><reportElement x="430" y="3" width="111" height="18" uuid="95b85246-2e67-42d0-9e41-987314cddba0"/><textElement textAlignment="Center"><font size="12" isBold="false"/></textElement><text><![CDATA[Price $]]></text></staticText><staticText><reportElement x="261" y="3" width="80" height="20" uuid="40050754-f800-4283-a0ed-64894f5652a2"/><textElement textAlignment="Center"><font size="12" isBold="false"/></textElement><text><![CDATA[Unit Cost $]]></text></staticText><staticText><reportElement x="10" y="3" width="50" height="20" uuid="299467fd-8d2b-48b0-af5b-769cc9d9bb37"/><textElement textAlignment="Center"><font size="12" isBold="false"/></textElement><text><![CDATA[Item]]></text></staticText><staticText><reportElement x="71" y="2" width="179" height="20" uuid="9818ad45-9dc2-4e62-821c-953f3801de84"/><textElement textAlignment="Center"><font size="12" isBold="false"/></textElement><text><![CDATA[Description]]></text></staticText><staticText><reportElement x="347" y="3" width="80" height="20" uuid="f10ae7d8-7499-404a-a1ab-a2ce63b22b3b"/><textElement textAlignment="Center"><font size="12" isBold="false"/></textElement><text><![CDATA[Quantity]]></text></staticText></band></columnHeader><detail><band height="29"><textField><reportElement x="11" y="5" width="54" height="20" uuid="0cd6aa63-bd20-45fb-8543-51931badd2fc"/><textElement textAlignment="Left"/><textFieldExpression><![CDATA[$F{itemNo}]]></textFieldExpression></textField><textField><reportElement x="70" y="5" width="180" height="20" uuid="1be950c3-370a-43fa-9510-2ee8db740774"/><textElement textAlignment="Left"/><textFieldExpression><![CDATA[$F{description}]]></textFieldExpression></textField><textField><reportElement x="261" y="5" width="80" height="20" uuid="3637c327-f832-4e7c-bb82-4cf41e607ca6"/><textElement textAlignment="Left"/><textFieldExpression><![CDATA[$F{unitCost}]]></textFieldExpression></textField><textField><reportElement x="347" y="5" width="80" height="20" uuid="e9bfe6dc-7101-4d22-90a7-4766122c4e8a"/><textElement textAlignment="Left"/><textFieldExpression><![CDATA[$F{quantity}]]></textFieldExpression></textField><textField><reportElement x="430" y="5" width="118" height="20" uuid="77c9d024-651d-4207-9f32-8637cd4dd449"/><textElement textAlignment="Left"/><textFieldExpression><![CDATA[$F{unitCost} * $F{quantity}]]></textFieldExpression></textField></band></detail><lastPageFooter><band height="177"><staticText><reportElement positionType="Float" x="-1" y="30" width="261" height="101" uuid="1a0d7088-5af7-4865-8be1-41ec5f51fb36"/><box><topPen lineWidth="1.1" lineStyle="Dashed"/><leftPen lineWidth="1.1" lineStyle="Dashed"/><bottomPen lineWidth="1.1" lineStyle="Dashed"/><rightPen lineWidth="1.1" lineStyle="Dashed"/></box><text><![CDATA[Your notes here]]></text></staticText><staticText><reportElement positionType="Float" mode="Opaque" x="0" y="147" width="556" height="30" backcolor="#E6E8E9" uuid="36aa233d-4305-48e6-974a-1bbf89bb3c8f"/><textElement textAlignment="Center" verticalAlignment="Middle"><font fontName="Serif" size="9" isItalic="true"/></textElement><text><![CDATA[THANKYOU FOR YOUR BUSINESS]]></text></staticText></band></lastPageFooter>
    </jasperReport>
  3. 创建一个Item类,它将作为模型对象,其中包含要绑定到JRXML模板字段的数据。 另外,我创建了一个InvoiceDetails类,该类具有将绑定到JRXML模板参数的数据。
    package com.ithinkisink.model;/*** * @author Belal**/
    public class Item {private String itemNo;private String description;private double unitCost;private int quantity;public Item(String itemNo, String description, double unitCost, int quantity) {super();this.itemNo = itemNo;this.description = description;this.unitCost = unitCost;this.quantity = quantity;}public String getItemNo() {return itemNo;}public void setItemNo(String itemNo) {this.itemNo = itemNo;}public String getDescription() {return description;}public void setDescription(String description) {this.description = description;}public double getUnitCost() {return unitCost;}public void setUnitCost(double unitCost) {this.unitCost = unitCost;}public int getQuantity() {return quantity;}public void setQuantity(int quantity) {this.quantity = quantity;}
    }
  4. DynamicReportsManagedBean将负责准备参数列表和包含将绑定到JRXML字段的Lis​​t <Item>的JRBeanCollectionDataSource。
    package com.ithinkisink.managedbean;import static net.sf.dynamicreports.report.builder.DynamicReports.report;import java.io.InputStream;
    import java.io.OutputStream;
    import java.io.Serializable;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.List;
    import java.util.Map;import javax.annotation.PostConstruct;
    import javax.enterprise.context.SessionScoped;
    import javax.inject.Named;
    import javax.servlet.ServletContext;import net.sf.dynamicreports.report.exception.DRException;
    import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;import com.ithinkisink.model.InvoiceDetails;
    import com.ithinkisink.model.Item;/*** * @author Belal**/
    @Named
    @SessionScoped
    public class DynamicReportsManagedBean implements Serializable {private static final long serialVersionUID = -1;private String invoiceName;private JRBeanCollectionDataSource beanCollectionDataSource;private Map<String, Object> parameters;@PostConstructpublic void init() {invoiceName="Invoice.jrxml";List<Item> itemList = new ArrayList<>(Arrays.asList(new Item("01", "Item 01 description", 1.1, 1), new Item("02", "Item 02 description", 2.2, 2),new Item("03", "Item 03 description", 3.3, 3)));beanCollectionDataSource = new JRBeanCollectionDataSource(itemList);parameters = (new InvoiceDetails("INV#01", "Billing Company", "Billing Company Add", "Billing Company State 1", "Billing Company State 2", "Shipping Name", "Shipping Address", "Shipping State 1", "Shipping State 2", 1000)).toMap();}/*** Preparing an output stream of the generated PDF invoice.* * @return*/public OutputStream getOS(ServletContext context, OutputStream outputStream) {parameters.put("IMAGE_PATH", context.getRealPath("/jasper/invoices"));InputStream is = context.getResourceAsStream("/jasper/invoices/" + invoiceName);try {report().setTemplateDesign(is).setDataSource(beanCollectionDataSource).setParameters(parameters).toPdf(outputStream);} catch (DRException e) {e.printStackTrace();}return outputStream;}// setters and getterspublic String getInvoiceName() {return invoiceName;}public void setInvoiceName(String invoiceName) {this.invoiceName = invoiceName;}public JRBeanCollectionDataSource getBeanCollectionDataSource() {return beanCollectionDataSource;}public void setBeanCollectionDataSource(JRBeanCollectionDataSource beanCollectionDataSource) {this.beanCollectionDataSource = beanCollectionDataSource;}public void setParameters(Map<String, Object> parameters) {this.parameters = parameters;}public Map<String, Object> getParameters() {return parameters;}
    }
  5. CDI使我们能够将DynamicReportsManagedBean的实例注入到DynamicReportsServlet。 Servlet将处理响应输出流,该响应输出流将显示从模板的DynamicReports创建的输出流。
    package com.ithinkisink.servlet;import java.io.IOException;
    import java.io.OutputStream;import javax.inject.Inject;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;import com.ithinkisink.managedbean.DynamicReportsManagedBean;/*** * @author Belal**/
    public class DynamicReportsServlet extends HttpServlet {private static final long serialVersionUID = 1L;@Injectprivate DynamicReportsManagedBean dynamicReportsManagedBean;@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {resp.setContentType("application/pdf");OutputStream out = resp.getOutputStream();out = dynamicReportsManagedBean.getOS(getServletContext(), out);out.close();}@Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {super.doPost(req, resp);this.doGet(req, resp);}public void setDynamicReportsManagedBean(DynamicReportsManagedBean dynamicReportsManagedBean) {this.dynamicReportsManagedBean = dynamicReportsManagedBean;}public DynamicReportsManagedBean getDynamicReportsManagedBean() {return dynamicReportsManagedBean;}
    }
  6. 在将servlet添加到web.xml中时,我更喜欢老派。
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"><display-name>DynamicReportsWithJSFServletsAndCDI Maven Webapp</display-name><servlet><description></description><display-name>DynamicReportsServlet</display-name><servlet-name>DynamicReportsServlet</servlet-name><servlet-class>com.ithinkisink.servlet.DynamicReportsServlet</servlet-class></servlet><servlet-mapping><servlet-name>DynamicReportsServlet</servlet-name><url-pattern>/*</url-pattern></servlet-mapping><welcome-file-list><welcome-file>/index.xhtml</welcome-file></welcome-file-list>
    </web-app>
  7. index.xhtml包含一个指向servlet的<iframe>。
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml"xmlns:h="http://java.sun.com/jsf/html"><h:head><title>DynamicReports with Servlets, JSF and CDI</title>
    </h:head><h:body><h:form><iframe name="receipt" height="600" id="theIFrame" width="100%"src="http://localhost:8080/DynamicReportsWithJSFServletsAndCDI" /></h:form>
    </h:body></html>
  8. 通过运行示例的最终输出。

    1-DynamicReportsWithJSFServletsAndCDI
  • 您可以从以下链接在我的Github上找到完整的示例: https : //github.com/belalgalal/Blogging/tree/master/DynamicReportsWithJSFServletsAndCDI

翻译自: https://www.javacodegeeks.com/2016/02/dynamicreports-jasperreports-jsf-servlet-cdi.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/354072.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

《Android进阶之光》--View体系与自定义View

No1&#xff1a; View的滑动 1&#xff09;layout()方法的 public class CustomView extends View{private int lastX;private int lastY;public CustomView(Context context,AttributeSet attrs,int defStyleAttr){super(context,attrs,defStyleAttr);}public CustomView(Cont…

js 数组 ajax php,js里面的对象ajax post到php端直接变成数组了?

本帖最后由 zhoumengkang 于 2013-09-12 10:03:14 编辑 事先引入了jqueryvar str "{a:b,aa:bb}";var str2 eval((str));var type typeof(str2);console.log(str);console.log(type);//objectconsole.log(str2);$.post(./bb.php,{data:str2});bb.php的代码$data $_…

【标签组件与图标 3.3】

1.图片图标。 SWing 利用javax.swing.ImageIcon 类根据现有图片创建图标&#xff0c;ImageIcon类实现了Icon接口&#xff0c;同时Java支持多种图片格式。 public ImageIcon&#xff08;&#xff09;:该构造方法创建了一个通用的ImageIcon对象&#xff0c;当正真需要设置图片时在…

swing 聊天气泡背景_Java Swing中的聊天气泡

swing 聊天气泡背景本文将向您解释“如何在Java swing应用程序中绘制聊天气泡&#xff1f;” 聊天气泡与呼出或提示气泡相同。 今天&#xff0c;大多数聊天应用程序都以这种格式显示转换&#xff0c;因此本文将帮助您在用Java swing创建的桌面应用程序中执行相同的操作。 以下课…

试述大数据对思维方式的重要影响

先讲大数据时代有哪些能做&#xff0c;哪些不能做&#xff1f;有一个很有名的科幻作家叫做阿西莫夫&#xff0c;写过《银河帝国》&#xff0c;也就是“基地系列”。据说本拉登就是看了他这本小说&#xff0c;把他自己的组织起名叫“基地组织”。阿西莫夫在书中提到&#xff0c;…

使用Spring AOP重试方法执行

我的一位博客关注者发送了一封电子邮件&#xff0c;要求我显示“ Spring AOP的RealWorld用法”示例。 他提到&#xff0c;在大多数示例中&#xff0c;都演示了Spring AOP在日志记录方法进入/退出或事务管理或安全性检查中的用法。 他想知道Spring AOP在“针对实际问题的真实项…

matlab绘制星下点轨迹,MATLAB绘制GPS星下点轨迹图

MATLAB绘制GPS星下点轨迹图轨迹计算部分参考链接&#xff1a;https://wenku.baidu.com/view/45bd098d4a7302768e9939cf.html本文对上述matlab代码进行了整理与修改&#xff1a;增加了底图并进行了相关的图形美化。将轨道六参数设置为GPS相关参数。从原有的1颗卫星轨迹绘制增加至…

jdk7与jdk8环境共存与切换

1&#xff0c;先安装jdk7,配置环境变量JAVA_HOME,然后安装jdk8。 2&#xff0c;安装jdk8后&#xff0c;JAVA_HOME指向未做修改&#xff0c;执行java -version显示还是以前的jdk7版本信息&#xff0c; 3&#xff0c;接下来我们配置环境变量JAVA_HOME,发现配置jdk7的路径,或者配置…

linux gcc matlab,Linux Matlab mex gcc 版本

一般MATLAB的mex支持的gcc版本都比最新的gcc要低一些&#xff0c;所以一般要配置一下。假设当前版本的gcc是4.8&#xff0c;matlab支持4.6&#xff0c;可以使用以下的方式解决(任选一种)。(自己装好gcc-4.6)修改安装目录下的mexopts.sh使用管理员权限&#xff0c;修改/usr/loca…

跨域/非跨域接口专题

跨域名的接口&#xff1a;A域名www.a.com请求B域名www.b.com的接口&#xff08;域名可以换成ip地址&#xff0c;同样成立&#xff09; 非跨域接口&#xff1a;A域名www.a.com请求A域名www.a.com的接口 对于跨域名的接口请求&#xff1a; 1. 如果是前端js请求&#xff0c;则需要…

在Java中模拟求和类型的巧妙解决方法

在继续阅读实际文章之前&#xff0c;我想感谢令人敬畏的Javaslang库的作者Daniel Dietrich &#xff0c;他在我面前有了这个主意&#xff1a; lukaseder尝试使用静态方法<T&#xff0c;T1扩展T&#xff0c;... Tn扩展T> Seq <T> toSeq&#xff08;T1 t1&#xff0…

PHP培训选云和数据,送给云和数据郑州分中心PHP培训班全体学员的祝福

在云和数据数百个日日夜夜&#xff0c;郑州PHP培训班的学员们一起成长&#xff0c;从青春懵懂到成熟稳重&#xff0c;从羞涩内敛到侃侃而谈&#xff0c;他们用奋斗和拼搏共同刻画了人生中一段难忘的回忆。12月12日&#xff0c;云和数据郑州分中心PHP培训班毕业典礼&#xff0c;…

关键字驱动小例子_example2

compute.py #该文件用来存被测函数#encodingUTF-8 import random import re def add(a,b):cint(a)dint(b)print cdreturn cddef sub(a,b):cint(a)dint(b)print c-dreturn c-ddef mul(a,b,c):dint(a)eint(b)fint(c)return d*e*fdef abs_value(a):return abs(int(a))def random_v…

学的php毫无兴趣,培训班学PHP,感觉兴趣越来越低,哎,真的很迷茫了!

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼人生在世&#xff0c;归纳而言&#xff0c;就是与两种人相处&#xff0c;一是自己&#xff0c;一是他人。 自处处人&#xff0c;就像在 画圆&#xff0c;以自觉、自度为圆心&#xff0c;以慈悲、利他为半径&#xff0c;所画出来的一…

cyclicbarrier_Java并发– CyclicBarrier示例

cyclicbarrierJava中的CyclicBarrier是JDK 5中在java.util.Concurrent包上引入的同步器&#xff0c;以及其他并发实用程序&#xff0c;例如Counting Semaphore &#xff0c; BlockingQueue &#xff0c; ConcurrentHashMap等。CyclicBarrier与CountDownLatch类似&#xff0c;我…

【XSY2720】区间第k小 整体二分 可持久化线段树

题目描述 给你你个序列&#xff0c;每次求区间第\(k\)小的数。 本题中&#xff0c;如果一个数在询问区间中出现了超过\(w\)次&#xff0c;那么就把这个数视为\(n\)。 强制在线。 \(n\leq 100000,a_i<n,w\leq n\) 题解 考虑整体二分。 先看看离线要怎么做。 现在我们要计算每…

php队列失败是指什么,队列是什么意思

队列是一种特殊的线性表。它只允许在表的前端(front)进行删除操作&#xff0c;而在表的后端(rear)进行插入操作&#xff0c;和栈一样&#xff0c;队列是一种操作受限制的线性表&#xff1b;进行插入操作的端称为队尾&#xff0c;进行删除操作的端称为队头&#xff1b;队列中没有…

从In Memory Data Grid,Apache Ignite快速入门

IMDG或内存数据网格不是内存中关系数据库&#xff0c;NOSQL数据库或关系数据库。 它是另一种软件数据存储库。 数据模型分布在单个位置或多个位置的许多服务器上。 这种分布称为数据结构。 这种分布式模型被称为“无共享”架构。 IMDG具有以下特征&#xff1a; 所有服务器可以…

python字典合并几种方式对比,Python合并两个字典的常用方法与效率比较

本文实例讲述了Python合并两个字典的常用方法与效率比较。分享给大家供大家参考。具体分析如下&#xff1a;下面的代码举例了5种合并两个字典的方法&#xff0c;并且做了个简单的性能测试#!/usr/bin/pythonimport timedef f1(d1,d2):return dict(d1,**d2)def f2(d1,d2):return …

91.91p10.space v.php,luogu P1091 合唱队形

任务计划推了很久才做www从两头开始的单调上升队列没啥可说的#include#includeusing namespace std;#define maxn 110int a[maxn];int f[2][maxn];int ans;int main() {int n;scanf("%d",&n);for(int i 1; i < n; i)scanf("%d",&a[i]);a[0] a…