我在发出POST请求时在error.userInfo中收到此响应AFNetworking.任何人都可以告诉我,我错过任何明显或需要修复我的服务器端的东西吗?
请求失败并显示错误:错误域= AFNetworkingErrorDomain代码= -1016"预期内容类型{("text/json","application/json","text/javascript")},得到text/html"UserInfo = 0x6d7a730 {NSLocalizedRecoverySuggestion = index test,AFNetworkingOperationFailingURLResponseErrorKey =,NSErrorFailingURLKey = http://54.245.14.201/,NSLocalizedDescription =预期内容类型{("text/json","application/json","text/javascript")},得到text/html,AFNetworkingOperationFailingURLRequestErrorKey = http://54.245.14.201/>},{AFNetworkingOperationFailingURLRequestErrorKey ="http://54.245.14.201/>"; AFNetworkingOperationFailingURLResponseErrorKey =""; NSErrorFailingURLKey ="http://54.245.14.201/"; NSLocalizedDescription ="预期内容类型{(\n \"text/json \",\n \"application/json \",\n
\"text/javascript \"\n)},得到text/html"; NSLocalizedRecoverySuggestion ="索引测试"; }
我正在使用此代码;
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
[httpClient registerHTTPOperationClass:[AFJSONRequestOperation class]];
[httpClient setDefaultHeader:@"Accept" value:@"application/json"];
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
@"Ans", @"name",
@"29", @"age",
nil];
NSMutableURLRequest *request = [httpClient requestWithMethod:@"POST" path:@"/" parameters:params];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSLog(@"Success");
NSLog(@"%@",JSON);
} failure:^(NSURLRequest …Run Code Online (Sandbox Code Playgroud) 所以我一直这样做,只要我记得,但我很好奇这是不是我应该做的.你编写一个带参数的函数,所以你预计它有一个值,但如果没有,你有充分的理由将它默认为零.我目前所做的是编写辅助函数:
function foo() { return foo(0); };
function foo(bar) { ... };
Run Code Online (Sandbox Code Playgroud)
我刚刚跑过一个我做过这个的实例,在理解我背后的逻辑之前,我奇怪地看了几秒钟.我来自php,它很简单:
function foo(bar=0) { ... }
Run Code Online (Sandbox Code Playgroud)
有没有我不知道的javascript替代品?
我有一个名为"myLocation"的CLLocation管理器.
myLocation = [[CLLocationManager alloc] init];
myLocation.desiredAccuracy = kCLLocationAccuracyBestForNavigation ;
myLocation.distanceFilter = 10 ;
myLocation.delegate=self;
locationEnabledBool = [CLLocationManager locationServicesEnabled];
if (locationEnabledBool ==NO || ( [CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied)) {
// LocationText.text = @"Location Service Disabled ";
UIAlertView *locationAlert = [[UIAlertView alloc] initWithTitle:@"Location Service Disabled"
message:@"To re-enable, please go to Settings and turn on Location Service for this app."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[locationAlert show];
[locationAlert release];
}
[myLocation startUpdatingLocation];
Run Code Online (Sandbox Code Playgroud)
和位置更新功能是
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
NSLog(@"old location is …Run Code Online (Sandbox Code Playgroud) 我想将函数调用(返回一个字符串)作为替换字符串传递给Powershell的替换函数,以便找到的每个匹配项都替换为不同的字符串.
就像是 -
$global_counter = 0
Function callback()
{
$global_counter += 1
return "string" + $global_counter
}
$mystring -replace "match", callback()
Run Code Online (Sandbox Code Playgroud)
Python允许通过're'模块的'sub'函数接受回调函数作为输入.寻找类似的东西
我在使用Hibernate事件监听器时喜欢PostDeleteEventListener, PostInsertEventListener, PostUpdateEventListener在插入,删除和更新期间执行一些操作.现在我想使用JPA监听器来执行此操作,因为如果我想从Hibernate移动到任何其他JPA提供程序,我的监听器应该工作.Hibernate监听器让我event可以从中获取事务并检查其是否已提交或回滚.JPA监听器只为我提供实体对象.现在我如何在JPA监听器中获取事务或会话或实体管理器?提前致谢!!我使用Jboss作为我的CMT.
我正在使用jQuery 网站上的 jQuery autocomplete插件 调用控制器url,返回json.问题是发送到控制器的参数始终为null.
以下是自动完成的浏览器内jQuery代码:
$(document).ready(function() {
var url = "/Building/GetMatchedCities";
$("#City").autocomplete(url);
});
Run Code Online (Sandbox Code Playgroud)
这是C#中的ASPNET MVC控制器签名:
public JsonResult GetMatchedCities(string city)
{
..
return this.Json(query, JsonRequestBehavior.AllowGet);
}
Run Code Online (Sandbox Code Playgroud)
提前致谢,
穆罕默德
DateTime.Now.AddMilliseconds(1.5); // adds 2 milliseconds
Run Code Online (Sandbox Code Playgroud)
他们到底在想什么呢?如果它不处理小数值,那么创建一个采用double的方法会让我感到非常糟糕.他们为什么不通过调用AddTicks实现这一点并正确处理分数?或者至少采用一个int,这样对调用者来说是透明的吗?
我猜他们必须有一个很好的理由让他们以这种方式实现它,但我想不出它会是什么.有人可以提供任何见解吗?
编辑:只是为了进一步强调这一点:
AddSeconds(1.5); // Adds 1500 milliseconds
Run Code Online (Sandbox Code Playgroud) 我在glassfish v3中创建连接池时遇到问题,仅供参考我正在使用Java EE glassfish包.
我的环境变量如下
Url: jdbc:oracle:thin:@localhost:1521:xe
User: sys
Password : xxxxxxxx
Run Code Online (Sandbox Code Playgroud)
我认为我需要建立一个连接.但我得到以下例外
WARNING: Can not find resource bundle for this logger. class name that failed: com.sun.gjc.common.DataSourceObjectBuilder
SEVERE: jdbc.exc_cnfe_ds
java.lang.ClassNotFoundException: oracle.jdbc.pool.OracleDataSource
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at com.sun.gjc.common.DataSourceObjectBuilder.getDataSourceObject(DataSourceObjectBuilder.java:279)
at com.sun.gjc.common.DataSourceObjectBuilder.constructDataSourceObject(DataSourceObjectBuilder.java:108)
at com.sun.gjc.spi.ManagedConnectionFactory.getDataSource(ManagedConnectionFactory.java:1167)
at com.sun.gjc.spi.DSManagedConnectionFactory.getDataSource(DSManagedConnectionFactory.java:135)
at com.sun.gjc.spi.DSManagedConnectionFactory.createManagedConnection(DSManagedConnectionFactory.java:90)
at com.sun.enterprise.connectors.service.ConnectorConnectionPoolAdminServiceImpl.getManagedConnection(ConnectorConnectionPoolAdminServiceImpl.java:520)
at com.sun.enterprise.connectors.service.ConnectorConnectionPoolAdminServiceImpl.getUnpooledConnection(ConnectorConnectionPoolAdminServiceImpl.java:630)
at com.sun.enterprise.connectors.service.ConnectorConnectionPoolAdminServiceImpl.testConnectionPool(ConnectorConnectionPoolAdminServiceImpl.java:442)
at com.sun.enterprise.connectors.ConnectorRuntime.pingConnectionPool(ConnectorRuntime.java:898)
at org.glassfish.admin.amx.impl.ext.ConnectorRuntimeAPIProviderImpl.pingJDBCConnectionPool(ConnectorRuntimeAPIProviderImpl.java:570)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.glassfish.admin.amx.impl.mbean.AMXImplBase.invoke(AMXImplBase.java:1038)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836) …Run Code Online (Sandbox Code Playgroud) 我有一个类的公共方法,我想记录该方法可以接受的可用字符串值。这是可以接受的吗:
/**
* Set size of photos
*
* @param string $size can be one of these options: url_sq, url_t, url_s, url_m, url_o
* @return void
*/
public function setSize($size){
$this->_size = $size;
}
Run Code Online (Sandbox Code Playgroud) 我使用JavaScript SDK进行Facebook Connect.昨天我加载了一个登录用户的所有朋友,如下所示:
https://graph.facebook.com/me/friends?fields=name,first_name,picture&access_token=MYACCESSTOKEN&callback=?
Run Code Online (Sandbox Code Playgroud)
使用此代码,我获得了登录用户拥有的所有朋友的ID,姓名,名字和图片.这是使用AJAX/jsonp调用的.正如我所说,它在昨天工作,从那以后没有对代码进行任何修改.
今天我得到了id,名字和名字 - 没有图片(!)这可能是Facebook Graph中的一个小故障,有没有我可能错过的任何更新或上面对图API的调用无效?
这是获取所有朋友照片的正确方法吗?
afnetworking ×1
asp.net-mvc ×1
autocomplete ×1
c# ×1
connection ×1
datetime ×1
field ×1
glassfish ×1
hibernate ×1
image ×1
ios ×1
iphone ×1
java ×1
java-ee ×1
javascript ×1
jboss7.x ×1
jpa ×1
jpa-2.0 ×1
jquery ×1
oracle ×1
php ×1
phpdoc ×1
powershell ×1
replace ×1
rounding ×1
string ×1