小编Thi*_*amy的帖子

从servlet访问WebContent中的文件

我尝试使用servlet的相对路径访问WebContent/alerts文件夹中的html文件.但我无法使用其相对路径访问它,

在此输入图像描述

使用相对路径从Servlet访问WebContent内的文件:

protected Element getSummary(String value) throws IOException
{
    Element element=null;
    Summary summary = Summary.valueOf(value);
    switch(summary) {
    case rtp_summary:
        element=parseDIV(new File("../../WebContent/alerts/rtp_bcklg_mail.html"),"rtp_summary");
        break;
    case ffu_summary:
        element=parseDIV(new File("/../../WebContent/alerts/ffu_comp_bcklg_mail.html"),"ffu_summary");
        break;    
    default:
        System.out.println("Enter a valid choice");
        break;
    }
    return element;
}
Run Code Online (Sandbox Code Playgroud)

使用相对路径从Java Thread访问WebContent内的文件:

 public class WriteJSONFile implements Runnable{

WriteJSONFile(){
}

@Override

public void run()
{
    try {
        createJSONFile();
    } catch (IOException e) {

        e.printStackTrace();
    }
}

@SuppressWarnings("unchecked")
private static void createJSONFile() throws IOException
{
    String path="C:/Users/Thiru/Documents/Website Design/Macaw/";
    JSONArray jsonArray=new JSONArray(); …
Run Code Online (Sandbox Code Playgroud)

java servlets vs-web-application-project servlet-3.0 jsoup

4
推荐指数
1
解决办法
1万
查看次数

如何将 HTML 表格转换为图表?

我有一些 JSON 数据,如下所示,其中包含国家/地区名称(KEY)和积压数量(VALUE)。

JSON 数据:

{“美国”:“50”,“西欧”:“100”,“加拿大”:“150”,“德国”:“200”,“法国”:“250”,“墨西哥”:“300” }

图表:

现在我想在图表中绘制这些值,例如

国家/地区名称 --> X 轴

待办事项计数 --> Y 轴

我怎样才能做到这一点?

代码:

 <html>
 <head>
    <title>RESTful Webservice JQuery client </title>
  </head>
  <body>
     <table id="results" border="1"></table>
     <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script> 
     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
     <script src="http://code.highcharts.com/highcharts.js"></script>
 <script>

         //When DOM loaded we attach click event to button
         $(document).ready(function() {

             //after button is clicked we download the data
             //$('.button').click(function(){

                 //start ajax request
                 $.ajax({
                     url: "data.json",
                     //force to handle it as json
                     dataType: "json",
                     success: function(data) {
                         //Stringify the Json
                        var …
Run Code Online (Sandbox Code Playgroud)

javascript jquery charts json highcharts

1
推荐指数
1
解决办法
2万
查看次数