我有另一个在iOS中构建的应用程序,当用户登录到应用程序时,服务器会在该会话中登录它们.在iOS应用程序中,只要正常会话和来自应用程序的所有请求都看到仍然登录的人,会话就会保持活动状态.
我以为这会是与Android应用程序相同,但登录我切换到下一个活动后,再发送到服务器的请求来填充页面.我回来的结果是说用户没有登录.
这里有什么不同,我不明白是不是让我的服务器上的会话还活着?
我有一个基类,我的所有活动都扩展,在基类中我有这个受保护的类.我用它来发送所有请求.
protected class API extends AsyncTask <Void, Void, String>
{
public String RequestName;
public String RequestType;
public String RequestUrl;
public List<NameValuePair> RequestParameters;
public API(String Name, String Type, String Url, List<NameValuePair> params)
{
RequestName = Name;
RequestType = Type;
RequestUrl = Url;
RequestParameters = params;
}
protected String getASCIIContentFromEntity(HttpEntity entity) throws IllegalStateException, IOException
{
InputStream in = entity.getContent();
StringBuffer out = new StringBuffer();
int n = 1;
while (n>0)
{
byte[] b = new byte[4096];
n = in.read(b); …Run Code Online (Sandbox Code Playgroud) 我在尝试拨打电话时收到错误消息 /api/subject/search
我认为这是一个我遗漏的简单语法错误
我的api路线定义如下
Route::group(array('prefix' => 'api'), function()
{
Route::post('resource/search', 'ResourceController');
Route::resource('resource', 'ResourceController');
Route::post('subject/search', 'SubjectController');
Route::resource('subject', 'SubjectController');
Route::resource('user', 'UserController');
Route::controller('/session', 'SessionController');
Route::post('/login', array('as' => 'session', 'uses' => 'SessionController@Store'));
});
Run Code Online (Sandbox Code Playgroud)
我的控制器大多是空的
class SubjectController extends \BaseController
{
public function search()
{
$subjects = [];
if((int)Input::get('grade_id') < 13 && (int)Input::get('grade_id') > 8)
$subjects = Subject::where('name', 'like', '%HS%')->get();
else
$subjects = Subject::where('name', 'not like', '%HS%')->get();
return Response::json([
'success' => true,
'subjects' => $subjects->toArray()
]);
}
/**
* Display a listing of the resource.
* …Run Code Online (Sandbox Code Playgroud) 我对此有点新鲜,所以如果我在完全错误的轨道上,请随时告诉我.
我有以下帖子架构.
var Post = new Schema( {
description: {
type: String,
default: '',
required: 'Please type a description',
trim: true
},
likeCount: {
type: Number,
default: 0
},
url: {
type: String,
default: '',
required: 'Unable to find photo',
trim: true
},
created: {
type: Date,
default: Date.now
},
user: {
type: Schema.ObjectId,
ref: 'User',
required: 'Unable to verify user'
},
comments: {
type: [Comment]
},
//Dynamically added values
hasLiked: {
type: Boolean
}
});
Run Code Online (Sandbox Code Playgroud)
以下是Like schema
var Like …Run Code Online (Sandbox Code Playgroud) 我试着查看其他一些问题,但找不到任何部分匹配.
我有两个 List<string>
他们有代码.一个是所选代码的列表,一个是所需代码的列表.整个代码列表虽然是树,所以它们有子代码.一个例子是代码B代码B.1代码B.11
所以假设所需的代码是B,但是它的树下的任何内容都将满足该要求,因此如果所选代码是A和C,则匹配将失败,但如果所选代码之一是B.1,则它包含部分匹配.
我只需要知道所选代码是否与任何所需代码部分匹配.这是我目前的尝试.
//Required is List<string> and Selected is a List<string>
int count = (from c in Selected where c.Contains(Required.Any()) select c).Count();
Run Code Online (Sandbox Code Playgroud)
我得到的错误是在Required.Any()上,它无法从bool转换为字符串.
对不起,如果这令人困惑,请告诉我是否添加任何其他信息会有所帮助.
一切正常,我做了一些更改,现在我的服务未定义。
我的_service文件夹中有一项基本服务
import config from 'config';
import { authHeader } from '../_helpers';
export const subscriptionService = {
getFullMenu
};
function getFullMenu() {
const requestOptions = {
method: 'GET',
headers: authHeader()
};
return fetch(`${config.apiUrl}/subscriptions/fullmealselection`, requestOptions).then(handleResponse);
}
function logout() {
// remove user from local storage to log user out
localStorage.removeItem('user');
}
function handleResponse(response) {
return response.text().then(text => {
const data = text && JSON.parse(text);
if (!response.ok) {
if (response.status === 401) {
// auto logout if 401 response returned from api …Run Code Online (Sandbox Code Playgroud) 启动一个新项目,并尝试设置数据库进行身份验证。我在 powershell 中运行以下命令。
dotnet ef database update -Context ApplicationDbContext
并得到以下错误Unrecognized option '-Context'
所以我尝试在不使用 -Context 选项的情况下运行它,只是为了查看和获取:
More than one DbContext was found. Specify which one to use. Use the '-Context' parameter
for PowerShell commands and the '--context' parameter for dotnet commands.
Run Code Online (Sandbox Code Playgroud)
我还尝试使用 --context 而不是 -context 运行它,但得到相同的错误。关于为什么它认识到我需要该选项,但同时又告诉我它不认识该选项,有什么建议吗?
我还重新启动了powershell。
我有一个名为Gym的课程
class Gym < ActiveRecord::Base
has_many :gym_users
has_many :users, :through => :gym_users
validates :name, :address1, :city, :state, :zip, :phone, :website, :presence => true
def has_admin_access?(user)
user.present? && gym_users.where(:user_id => user.id, :gym_role_id => 3)
end
end
Run Code Online (Sandbox Code Playgroud)
我想修改has_admin_access方法以查找3或4的gym_role_id.另一个问题是我如何做小于或大于?
某处有在线备忘单吗?
这是一些代码,它是我的控制器的基类,初始化所有常见值.该文件位于我的模型文件夹中,如果这有所不同.奇怪的是它在我正在开发的MAMP本地工作,但不在服务器上.我在想它可能是一个配置问题?
<?php
Zend_Loader::loadClass('Zend_Controller_Action');
class BaseController extends Zend_Controller_Action
{
protected $auth;
protected $current_user;
protected $db;
protected function initialize_values()
{
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity())
{
$this->$current_user = $auth->getIdentity();
$this->view->user = $this->$current_user;
}
$this->db = Zend_Registry::get('dbAdapter');
$this->view->controller_name = $this->_request->getControllerName();
$this->view->view_name = $this->_request->getActionName();
}
}
Run Code Online (Sandbox Code Playgroud)
我把它放在if语句中的第一行
$this->$current_user = $auth->getIdentity();
Run Code Online (Sandbox Code Playgroud)
我理解这个错误意味着它试图访问不存在的属性或方法.在这种情况下,我知道存在
我对javascript的理解一直是代码按顺序执行,因此下一行直到它执行上一行才执行.
我有类似以下的东西,我试图尝试一次保存一系列问题.
for(var i = 1; i <= assessment_question_count; i++)
{
if(valid)
{
var sort = i;
$.ajax(
{
type: "POST",
url: '/assessmentquestion/create',
data: 'assessment_id=' + assessment[1] + '&question_text=' + $('#assessment_question_text_' + sort).val() + '&assessment_question_type_id=' +
$('assessment_question_type_' + sort).val() + '&sort_order=' + i,
success: function (str)
{
var result = str.split('|');
if (result[0] == 'success')
{
var message = '<br />Question saved ';
update_display_message(message);
}
else if(result[0] == 'fail')
{
valid = false;
var message = '<br />Error saving question …Run Code Online (Sandbox Code Playgroud) 我有以下方法,我试图确定某人与练习有关.来自C#这似乎是正确的方法,但我在这里得到一些警告/错误.
- (BOOL) isAvailablePractice:(NSString*)practiceId
{
BOOL *check = NO;
for(NSUInteger i = 0; i < [self.practices count]; i++)
{
EHRXOption *o = [self.practices objectAtIndex:i];
if([o.id isEqualToString:practiceId])
check = YES;
}
return check;
}
Run Code Online (Sandbox Code Playgroud)
在线上我设置check = YES我收到以下警告
Incompatible integer to pointer conversion assigning to 'BOOL *' (aka 'signed char *') from 'signed char';
Run Code Online (Sandbox Code Playgroud)
在返回检查我得到此错误
Incompatible pointer to integer conversion returning 'BOOL *' (aka 'signed char *') from a function with result type 'BOOL' (aka 'signed char'); dereference with *
Run Code Online (Sandbox Code Playgroud)
我理解这个错误的方式,我可能是错的,如果我在返回*前面放一个*检查它实际上会返回一个新值而不是我一直在使用的那个.
我真的不明白Objective …
我正在测试Android应用程序的JSON功能,并具有以下JSON对象.
{"result":"fail"}
Run Code Online (Sandbox Code Playgroud)
然后我使用以下代码来获取我的值:
JSONObject jObject = new JSONObject(ReturnValue); //Return value is what's shown above
String r = jObject.getString("result");
Run Code Online (Sandbox Code Playgroud)
然后使用以下我没有得到匹配
if(r.trim() == "fail")
Run Code Online (Sandbox Code Playgroud)
我把它写到屏幕上只是为了确保这个:
et.setText("-" + r + "-");
Run Code Online (Sandbox Code Playgroud)
这导致 - 失败 -
我不明白为什么这不匹配.如果我使用r.Contains它返回true,但我不能将它用于我的检查.