我正在构建一个PHP RESTful API,遵循本教程.以下函数应该在使用'put'方法时返回随请求一起发送的数据,每次都返回null:
file_get_contents('php://input').
我甚至已经下载并测试了教程中的完整代码示例,它仍然返回null.
我正在使用cURL和以下命令来测试'put'方法:
curl -i -X PUT -d '{"address":"Sunset Boulevard"}' http://localhost/clients/ryan.
我已经浪费了很多时间,仍然没有阅读json数据.我究竟做错了什么?
我正在使用多个构建和应用程序,JTables我需要检测何时发生单元格值更改,以便我可以在数据库中更新它.我尝试TableModelListener并覆盖tableChanged,但只有在我编辑完单元格后单击(单击另一行)时才会触发.
还有其他办法吗?
我有一个shadowbox脚本.当我加载页面时一切正常,但是当我调用此jquery加载函数然后尝试通过单击图像触发阴影框时,大图像将在新窗口中打开.这是代码:
<link href="CSS/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="shadowbox-3.0.3/shadowbox.js"></script>
<script type="text/javascript">
Shadowbox.init();
</script>
<p id="compas"><a href="images/coverage.jpg" rel="shadowbox" title="Coverage map"></a></p>
Run Code Online (Sandbox Code Playgroud)
知道为什么会这样吗?
我试图使用c#设置端口转发,但我在visual studio中不断收到此错误.
Interop type 'NATUPNPLib.UPnPNATClass' cannot be embedded. Use the applicable interface instead.
这是代码:
NATUPNPLib.UPnPNATClass upnpnat = new NATUPNPLib.UPnPNATClass();
NATUPNPLib.IStaticPortMappingCollection mappings = upnpnat.StaticPortMappingCollection;
mappings.Add(9099, "UDP", 9099, "192.168.1.101", true, "Local Web Server");
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我在这里找到了代码.
我有一个JPopUpMenu,我添加到多个JTables,我想获得右键单击的特定表,以便我可以对其进行更改.如何在Action Listener中获取触发JPopupMenu的组件?
JPopupMenu popupMenu = new JPopupMenu();
JMenuItem menuItemRename = new JMenuItem("Rename");
popupMenu.add(menuItemRename);
table.getTableHeader().setComponentPopupMenu(popupMenu);
ActionListener menuListener = new ActionListener() {
public void actionPerformed(ActionEvent event) {
String newTitle = JOptionPane.showInputDialog(null, "Enter new title");
//Get the table and rename it here
}
};
menuItemRename.addActionListener(menuListener);
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用PHP开发RESTful API而不使用框架.处理请求时,无法使用以下方法读取客户端数据:parse_str(file_get_contents("php://input"), $put_vars);
这是完整的代码:
public static function processRequest() {
//get the verb
$method = strtolower($_SERVER['REQUEST_METHOD']);
$request = new Request();
$data = array();
$put_vars = array();
switch ($method) {
case 'get':
$data = $_GET;
break;
case 'post':
$data = $_POST;
break;
case 'put':
parse_str(file_get_contents("php://input"), $put_vars);
$data = $put_vars;
echo $data;
break;
}
$request->setMethod($method);
$request->setRequestVars($data);
if (isset($data['data'])) {
$request->setData(json_decode($data));
echo 'data exists';
}
return $request;
}
Run Code Online (Sandbox Code Playgroud)
我正在使用cURL来休息API,当我输入这个命令时:curl -i -X PUT -d '{"name":"a","data":"data1"}'
http://localhost/my-rest-api/api/我只能得到这个:
Array""
为什么没有返回正确的数据?
编辑
我还测试了 …
我花了很长时间搜索这个,我只找到了GroupableHeader代码.我在2列中需要一个超过2列的标题JTable.如何在不使用臭名昭着GroupableHeader的情况下完成,同时保持`JTableHeader的默认外观?
这是我想到的图形表示:
_________________________
| Table Header |
|-----------------------|
| | |
|-----------|-----------|
| | |
|-----------|-----------|
Run Code Online (Sandbox Code Playgroud) 这是我的主要方法,它包含一个 shutdownhook:
public static void main(String args[]) {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
JOptionPane.showMessageDialog(null, "Shutdown hook");
}
});
/* Create and display the form */
java.awt.EventQueue.invokeLater(
new Runnable() {
@Override
public void run() {
Thread.setDefaultUncaughtExceptionHandler(new MyUncaughtExceptionHandler());
MyFrame frame = new MyFrame();
frame.setVisible(true);
}
});
}
Run Code Online (Sandbox Code Playgroud)
问题是JOptionPane根本不显示。相反,框架会关闭,但应用程序本身仍然运行。附言。我无法使用该WindowClosing事件,因为它不会在Mac OS XCmd上的+Q命令上触发。
我的应用程序中有一个DataGridView,我无法使用鼠标滚轮滚动它.过去以前工作得很好.我不知道我做了什么导致这个因为我最近在我对代码进行了多次更改之后才注意到它.
我没有发布任何代码,因为有超过2k行,我不确定错误可能在哪里.
可能导致这种情况的任何想法?如果您需要任何代码我可以在之后编辑问题.
我正在开发一个具有需要多行单元格的JTable的应用程序.因此我扩展了JTextArea并显示了所有内容,但是当我尝试编辑单元格时.文本显示在一行中,编辑后变为多行显示.我希望文本在编辑期间保持多线.有没有办法做到这一点?
我有一个函数需要在布尔变量为真时调用.我尝试在线程中使用while循环,但它不起作用.这是我尝试过的:
public class MyRunnable implements Runnable {
public void run() {
while (true) {
if (conditions == true) {
System.out.println("second");
break;
}
}
}
public static void main(String args[]) {
boolean condition = false;
(new Thread(new MyRunnable())).start();
System.out.println("first\n");
// set conndition to true
condition = true;
}
}
Run Code Online (Sandbox Code Playgroud)
结果应该是:
first
second
Run Code Online (Sandbox Code Playgroud) java ×6
swing ×5
jtable ×4
c# ×2
curl ×2
json ×2
php ×2
rest ×2
api ×1
datagridview ×1
events ×1
javascript ×1
jpopupmenu ×1
jquery ×1
jtableheader ×1
jtextarea ×1
listener ×1
shadowbox ×1
tablemodel ×1
upnp ×1