我正在尝试在Yii2高级应用程序中构建REST API,以管理对我的数据库的简单查询.在一些教程之后,最后逐步构建指南中的示例,在"快速入门"中,让我的模型适用于GET和HEAD方法.
在模块中创建我的API服务,使用最少的设置正确设置,在backend/main.php上请求JSON解析器,在common/main.php中注册模块并在urlManager中创建规则(在最小的通常规则下面,enablePrettyUrl ,控制器/动作,......):
['class' => 'yii\rest\UrlRule', 'controller' => ['precapi']]
Run Code Online (Sandbox Code Playgroud)
但每当我尝试其他方法时,通过CURL或Postman REST Client,它总会给我一个405错误:
方法不允许.此URL只能处理以下请求方法:GET,HEAD.
我想我已经尝试了很多不同的配置和路径试图解决它,但没有任何结果.唯一的问题是'enableStrictParsing' => false'在urlManager中,因为它在某些URL上给出了404错误,而POST也不能用于此,尽管应用程序正常工作.
任何帮助将不胜感激.问候.
我只能把头撞在墙上.我不明白,为什么我的以下快速排序算法不起作用.它是用Pascal编写的:
program quicksort;
Type iArray = array [0..8] of integer;
var intArray, newArray : iArray;
Function getIntArray(localIntArray : iArray) : iArray;
begin
localIntArray[0] := 3;
localIntArray[1] := 1;
localIntArray[2] := 8;
localIntArray[3] := 4;
localIntArray[4] := 9;
localIntArray[5] := 0;
localIntArray[6] := 8;
localIntArray[7] := 2;
localIntArray[8] := 5;
getIntArray := localIntArray;
end;
Procedure writeArray(localIntArray : iArray);
var i:integer;
begin
for i:=low(localIntArray) to high(localIntArray) do begin
write(localIntArray[i]);
end;
writeln('');
end;
Procedure quicksort(links : integer ; rechts:integer; localIntArray : iArray);
// …Run Code Online (Sandbox Code Playgroud) I have a HashMap<Vertex, Integer> called vertexIndexes. If I iterate through it with this code:
public boolean search(String vertexName){
for (Vertex name: vertexIndexes.keySet()){
String key = name.toString();
String value = vertexIndexes.get(name).toString();
System.out.println(key + " " + value + " "+ (name.hashCode() == vertexName.hashCode()) + " " + name.equals(vertexName));
}
...
}
Run Code Online (Sandbox Code Playgroud)
it produces this output:
Diessen 0 false false
Herrsching 5 false false
Schondorf 2 false false
Greifenberg 3 false false
Stegen 4 false false
Utting 1 false false …Run Code Online (Sandbox Code Playgroud) 我想实现一个单独的ErrorHandler类,它显示某些事件的错误消息.应该从不同的其他类调用此类的行为.发生错误时,它将具有UIAlertView输出.此AlertView的显示应始终位于顶部.因此无论从何处抛出Error,最顶层的viewController都应该显示AlertMessage(例如,当异步后台进程失败时,我想要一条错误消息,无论前景中显示什么View).
我找到了几个似乎可以解决我的问题的要点(见下面的代码).但是调用UIApplication.sharedApplication().keyWindow?.visibleViewController()确实会返回一个零值.
从要点扩展
extension UIWindow {
func visibleViewController() -> UIViewController? {
if let rootViewController: UIViewController = self.rootViewController {
return UIWindow.getVisibleViewControllerFrom(rootViewController)
}
return nil
}
class func getVisibleViewControllerFrom(vc:UIViewController) -> UIViewController {
if vc.isKindOfClass(UINavigationController.self) {
let navigationController = vc as! UINavigationController
return UIWindow.getVisibleViewControllerFrom( navigationController.visibleViewController)
} else if vc.isKindOfClass(UITabBarController.self) {
let tabBarController = vc as! UITabBarController
return UIWindow.getVisibleViewControllerFrom(tabBarController.selectedViewController!)
} else {
if let presentedViewController = vc.presentedViewController {
return UIWindow.getVisibleViewControllerFrom(presentedViewController.presentedViewController!)
} else {
return vc;
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 我使用此方法来显示UIDocumentPicker:
func showDocumentPicker(){
let docPicker = UIDocumentPickerViewController(documentTypes: ["public.composite-content "], inMode: UIDocumentPickerMode.Import)
docPicker.delegate = self
docPicker.modalPresentationStyle = UIModalPresentationStyle.FullScreen
self.presentViewController(docPicker, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
UIDocumentPicker很好地显示,但它总是显示
无文档,iCloud Drive中的文档不可用,因为禁用了iCloud Documents&Data设置

但是当我检查iCloud状态时,iCloud Drive已启用!(我的应用程序甚至出现在那里的设置中,也启用了!)

这发生在模拟器和设备上(通过Apple TestFlight分发的预发布)
我有一个名为HtmlConnect.java的类.我声明变量log如下:
public Log log = Log.getInstance();
Run Code Online (Sandbox Code Playgroud)
Log.java文件如下所示:
public class Log {
private static Log instance = null;
private String log;
private Log() {
}
public static Log getInstance() {
if (instance == null) {
instance = new Log();
}
return instance;
}
public String getLog() {
return log;
}
public void appendLog(String message) {
this.log.concat(message+"\n");
}
}
Run Code Online (Sandbox Code Playgroud)
所以我打电话的时候
log.appendLog("TestLog");
Run Code Online (Sandbox Code Playgroud)
我总是得到一个nullpointer异常.为什么是taht?
自从更新到 gradle 6.2.2 以来,bintray 发布变得疯狂。Bintray 显示工件名称而不是版本号,并且该库无法使用此操作。
有没有人经历过这种情况或知道为什么会发生这种情况?
编辑:切换到 5.6.3 gradle 包装器将按预期上传库(没有工件/版本号命名问题)