我正在尝试从我的visual studio 2013环境中读取json文件。如下所述,它会抛出一些错误
plnkr
然而,它在import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTextArea;
public class DataManager extends JFrame {
private String students[] = {"John Smith","Ken Hanson","Michael Li","John Andersen","Fiona Harris","Angela Lim","Bob London","Sydney Shield","Tina Gillard",
"Ross Brinns","Scott Cairns","Grant Peterson","David Power","Joshua Kane","Alan Newton","Frady Morgan","Quinn Perth"};
private int english[] = {80,52,71,61,39,62,31,46,60,26,77,40,58,38,94,90,97};
private int maths[] = {60,45,77,90,45,55,66,87,31,42,65,55,80,71,51,55,95};
private int total[];
private JButton sortNameButton;
private JButton sortTotalButton;
private JTextField searchTextField;
private JButton statisticsButton;
private JButton exitButton;
private JTextArea infoTextArea;
private JPanel jPan;
public DataManager() {
super("Data Manager ");
jPan = new JPanel();
sortNameButton = new JButton("Sort By Name");
sortTotalButton = new JButton("Sort By Total");
searchTextField = new JTextField("Search");
statisticsButton = new JButton("Statistics");
exitButton = new JButton("Exit");
infoTextArea = new JTextArea();
setLayout(new BorderLayout());
jPan.add(sortNameButton, BorderLayout.NORTH);
jPan.add(sortTotalButton, BorderLayout.NORTH);
jPan.add(searchTextField, BorderLayout.NORTH);
jPan.add(statisticsButton, BorderLayout.NORTH);
jPan.add(exitButton, BorderLayout.NORTH);
jPan.add(infoTextArea, BorderLayout.CENTER);
}
public static void main(String[] args) {
DataManager frame = new DataManager();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800,600);
frame.setVisible(true);
} // End of main method.
} // End of DataManager class
http://plnkr.co/edit/std1ngB40YIJBmC94Zdm?p=preview
有人可以告诉我如何解决这个问题吗?
错误截屏
答案 0 :(得分:-1)
您是否正确设置了mime地图?我只看到处理程序映射的截图。
如果仍然无法正常工作,请删除已完成的脚本地图,并坚持使用mime地图,我不知道你为什么要首先添加脚本地图。
答案 1 :(得分:-1)
我对这个问题做了很多研究,最后解决了:) :)
我也尝试了@James Trotter给出的答案,但没有成功。
我不知道为什么IIS中的MIME不起作用,但是当我在web.config
中添加它时它才起作用解决方案:
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
了解更多信息
Allow loading of JSON files in Visual Studio Express 2013 for Web