小编mrj*_*_05的帖子

如何调用使用Reflection接受Map作为输入参数的私有方法?

我试图使用反射在我的一个类中调用一个私有方法,它也接受一个Map参数.

下面是我应该调用的方法,下面的方法是ReflectionTest:

private static Map<String, String> storageSort(final List<Map<String, String>> employeeList) {

}
Run Code Online (Sandbox Code Playgroud)

我这样调用上面的方法:

ReflectionTest io = new ReflectionTest();
Method m = ReflectionTest.class.getDeclaredMethod("storageSort", Map.class);
m.setAccessible(true); 
Object o = m.invoke(io, sortList);
Run Code Online (Sandbox Code Playgroud)

但以下是我每次都会得到的例外情况:

java.lang.NoSuchMethodException:com.reflection.test.ReflectionTest.storageSort(java.util.Map)

我不确定我在这里做错了什么?

java reflection map

0
推荐指数
1
解决办法
993
查看次数

error_handler()或set_error_handler()

我在书中练习了一下考试(webbot,sspider,sscreen和scrapers),但考试不顺利.

结果是 :Warning: set_error_handler() expects the argument (BAD RESULT0) to be a valid callback

<?php
    include("LIB/LIB_http.php");
    $page = http_get($target="http://123blablabla",$ref="");
    if($page['STATUS']['http_code']!="200")
        set_error_handler("BAD RESULT".$page['STATUS']['http_code']);
?>
Run Code Online (Sandbox Code Playgroud)

有人可以帮我如何使用error_handler()set_error_handler()

php function

0
推荐指数
1
解决办法
2776
查看次数

PHP爆炸无法正常工作

这可能看起来微不足道,但它伤害了我的头脑.有人可以解释原因http://php.net/manual/es/function.explode.php示例显示(我已经修剪过).

$pizza  = "piece1 piece2 piece3"; // string
$pieces = explode(" ", $pizza);
// after a var dump
array(3) {  [0]=> string(6) "piece1" 
            [1]=> string(6) "piece2" 
            [2]=> string(6) "piece3" }
Run Code Online (Sandbox Code Playgroud)

这很可爱,删除了所有的空间并做了一个很好的小数组,但是当我使用下面显示的类似的东西时

$path = "/test-gallery/2/"; // string
$urlpieces = explode("/", $path);
// after a var dump
array(4) {  [0]=> string(0) "" 
            [1]=> string(12) "test-gallery" 
            [2]=> string(1) "2" 
            [3]=> string(0) "" }
Run Code Online (Sandbox Code Playgroud)

我得到第一个和最后一个空字符串.为什么不删除第一个和最后一个数组元素?我总是可以添加另一个步骤并删除它,但爆炸应该把它全部拿出来不应该吗?

在此先感谢您的建议.

php explode

0
推荐指数
1
解决办法
8873
查看次数

PHP获取文件内容

我试图在另一个网站上显示一个网站的内容.这就是我目前拥有的:

<?php 
  $file = file_get_contents ('http://linkto.com/the-page'); 
  echo $file; 
?>
Run Code Online (Sandbox Code Playgroud)

它从该页面获取所有内容.但是,我只需要从中获取一个表.我基本上只需要从所有的内容<table id=arc>,以</table>.

有没有简单的方法来编辑我的代码才能获得该表?

php file-get-contents

-3
推荐指数
1
解决办法
4003
查看次数

请解释一下 - xmlhttp.open("GET","gethint.php?q ="+ str,true);

在此代码行中:

xmlhttp.open("GET","gethint.php?q="+str,true);
Run Code Online (Sandbox Code Playgroud)

是什么意思gethint.php?q="+str以及为什么这很重要?

php ajax mysqli die

-3
推荐指数
1
解决办法
4674
查看次数

标签 统计

php ×4

ajax ×1

die ×1

explode ×1

file-get-contents ×1

function ×1

java ×1

map ×1

mysqli ×1

reflection ×1