我创建了一个节点js服务器。我发送的HTML文件包含以下行:
<script type="text/javascript" src="jquery.js"></script>
我的应用安排如下:
服务器发送index.html文件。 当我按F12时,我收到以下错误:
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8080/jquery.js
我还尝试更改jquery文件的目录,但它仍然给我错误。
任何解决方案?感谢...
答案 0 :(得分:1)
尝试此操作来提供Set<Map.Entry<Integer, String>> entrySet = FiftyStates.entrySet();
DefaultComboBoxModel model = new DefaultComboBoxModel();
for (Map.Entry<Integer, String> entry : entrySet) {
model.addElement(entry);
}
JComboBox cb = new JComboBox(model);
cb.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value instanceof Map.Entry) {
value = ((Map.Entry)value).getValue();
}
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
});
JOptionPane.showMessageDialog(null, cb, "Select State", JOptionPane.QUESTION_MESSAGE);
Object selectedItem = cb.getSelectedItem();
if (selectedItem != null && selectedItem instanceof Map.Entry) {
Map.Entry<Integer, String> entry = (Map.Entry<Integer, String>) selectedItem;
JOptionPane.showMessageDialog(null, "You selected " + entry.getKey() + "/" + entry.getValue());
}
目录中的静态文件:
scripts
答案 1 :(得分:0)
在server.js中添加此内容
app.use(express.static(__dirname + '/javascripts'));
比用
检索<script type="text/javascript" src="javascripts/jquery.js"></script>
答案 2 :(得分:-2)
如果jQuery位于名为scripts
的目录中,则应为:
<script type="text/javascript" src="scripts/jquery.js"></script>