小编Kri*_*rma的帖子

在速度模板中转义引号

我有一个java方法,需要几个字符串.需要从Velocity Template调用此方法.但是,字符串太复杂,有很多单引号,双引号和逗号.结果合并失败了.有没有办法逃避Velocity的报价?

java quotes velocity

21
推荐指数
1
解决办法
2万
查看次数

重置jquery分页插件中的总页数

我正在使用TwbsPagination插件在我的应用程序中显示分页.我们在初始化时设置页面大小时工作正常.但是,根据搜索结果,我想重置总页数.

当我尝试使用时

$('#pagination').twbsPagination({totalPages:10});
Run Code Online (Sandbox Code Playgroud)

它没有重置显示的总页数.

jquery reset jquery-pagination

14
推荐指数
3
解决办法
1万
查看次数

在jqgrid中使用自定义函数调用的超链接/按钮

我想在jqgrid的每一行中添加一个超链接/按钮,它会触发一个自定义的javascript函数.厌倦了各种试验.

jQuery('#ProductListGrid').jqGrid({
    url: '/Product/ProductListGrid',
    datatype: 'json',
    multiselect: true,
    height: 250,
    autowidth: true,
    mtype: 'GET',
    loadComplete: addlinks,
    colNames: ['ProductId', 'ProductName', 'edit'],
    colModel: [
      { name: 'ProductId', index: 'ProductId',key:true, width: 70, hidden: true, editable: true, size: 5 },
      { name: 'ProductName', index: 'ProductName', width: 70, editable: true },
      { name: 'edit', index: 'edit', width: 70},

    ],
    pager: jQuery('#ProductListGrid_pager'),
});
function addlinks() {
    var ids = jQuery("#ProductListGrid").getDataIDs();
    alert(ids);
    for (var i = 0; i < ids.length; i++) {
        be = "<a href='#' style='height:25px;width:120px;' …
Run Code Online (Sandbox Code Playgroud)

javascript jquery jqgrid

5
推荐指数
1
解决办法
6790
查看次数

如何使用sourcetree将dll添加到bitbucket

我正在尝试将.net项目上传到bitbucket存储库.为此,我使用的是atlassian SourceTree.首先,当我上传工作目录时,它没有显示工作副本更改或暂存更改中的dll.

但是在更改全局忽略列表(tools-> options-> Git-> EditFile)后,删除了dll条目,它开始显示.但是,分阶段的变化并没有推向存储库.它总是说是最新的.

git dll atlassian-sourcetree

4
推荐指数
1
解决办法
7223
查看次数

Azure:上下文在Code First模式下使用,代码是从EDMX生成的

我有MVC应用程序在本地运行良好.更新到Azure后,它开始抛出错误:

在Code First模式中使用上下文,其中包含从EDMX文件生成的用于Database First或Model First开发的代码.这将无法正常工作.要解决此问题,请不要删除引发此异常的代码行.如果您希望使用Database First或Model First,请确保Entity Framework连接字符串包含在启动项目的app.config或web.config中.

我检查了本地web.config和azure web.config之间是否有任何区别.除了凭证,一切都是一样的.它读到:

<add name="DBEntities" 
     connectionString="metadata=res://*/DBModel.csdl|res://*/DBModel.ssdl|res://*/DBModel.msl;
                       provider=System.Data.SqlClient;
                       provider connection string=&quot;data source=xx;initial catalog=xx;persist security info=True;user id=xx;password=xx;MultipleActiveResultSets=True;application name=EntityFramework&quot;" 
     providerName="System.Data.EntityClient" />
Run Code Online (Sandbox Code Playgroud)

我使用的是EF 6.1.3,MVC5

database connection-string azure entity-framework-6

4
推荐指数
2
解决办法
3583
查看次数

用于派生功能的增强基类方法 - 减少代码

典型情况如下.

class ServiceBase
{
    public virtual InstanceBase GetObject() { return null; }
}

class ServiceA : ServiceBase
{
    public override InstanceBase GetObject()
    {
        var v = new InstanceA();
        v.Method();
        return v;
    }
}

class ServiceB : ServiceBase
{
    public override InstanceBase GetObject()
    {
        var v = new InstanceB();
        v.Method();
        return v;
    }
}

class InstanceBase
{
    public virtual void Method() { }
}

class InstanceA : InstanceBase
{
    public override void Method(){}
}

class InstanceB : InstanceBase
{
    public override …
Run Code Online (Sandbox Code Playgroud)

c# instance derived-class

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

常见的@before和@after用于junit中的测试类

是否可以使用可在多个测试类中使用的通用@Before@After固定装置?

我已根据模块(库存,销售,采购等)将测试(分类)分开.对于所有这些测试,用户登录是一个先决条件,目前我正在@Before为每个类使用它.问题是当我需要更改用户ID或密码时,我需要更改每个类.有没有办法编写@Before/ @After可以在所有测试类中使用?在这种情况下,测试套件是否可以派上用场?

java junit4 testcase

3
推荐指数
2
解决办法
1278
查看次数

用命名函数替换匿名函数(在jQuery中)

我的原始(工作)代码如下所示:

jQuery().ready(function ($) {
    $('[id="errorMessages"]').ajaxStart(function () {
        $(this).html("");
    });
    $('[id="errorMessages"]').ajaxError(function (e, jqxhr, settings, exception) {
        //...
    });
});
Run Code Online (Sandbox Code Playgroud)

当我试图将匿名函数替换为命名函数时,调用如下:(我正在为某些需求做一个POC,期望这样的实现.)

function fs() {
        $(this).html("");
}
function fe(e, jqxhr, settings, exception) {
        //...
}
jQuery().ready(function ($) {
    $('[id="errorMessages"]').ajaxStart(fs());
    $('[id="errorMessages"]').ajaxError(fe(e, jqxhr, settings, exception));
});
Run Code Online (Sandbox Code Playgroud)

我收到一个错误,说明参数'e'未定义.但没有参数的函数似乎工作正常.

我想知道匿名函数如何接收参数,而调用外部函数时则不可用.

有没有办法将这些参数化的匿名函数转换为常规函数调用.

javascript parameters jquery anonymous-function

2
推荐指数
1
解决办法
1226
查看次数

CodeIgniter中的自定义异常

我想扩展在调用getMessage时返回自定义消息的异常类.

class MY_Exceptions extends CI_Exceptions{
     function __construct(){
        parent::__construct();
    }
    function getMessage(){
        $msg = parent::getMessage();
        return "ERROR - ".$msg;
    }
}
Run Code Online (Sandbox Code Playgroud)

MY_Exceptions放在核心文件夹中.抛出/处理异常如下:

try{
    throw new Exception('a message');
}catch (Exception $e) {
        echo $e->getMessage();
}
Run Code Online (Sandbox Code Playgroud)

目的是得到"错误 - 一条消息".但它总是返回"消息".当我尝试调试时,控件永远不会进入MY_Exception类.有什么我想念的吗?

codeigniter exception custom-exceptions

2
推荐指数
1
解决办法
4743
查看次数

删除visual studio 2012中的尾随空格

我想从文本文件中删除每行的尾随空格,保持换行符不变.我正在使用Visual Studio 2012的Regex功能.

当我试图找到\s*\r?\n并替换\r\n它时,也剥离了所有空行,这是不期望的.

有什么我想念的吗?

regex visual-studio-2012

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

无法在GetTypes方法上加载文件或程序集错误

我正在从文件夹中读取dll和进程类型。

xxx.dll
xxx.interfaces.dll
Run Code Online (Sandbox Code Playgroud)

当我加载xxx.dll并在该程序集上调用GetTypes时,它将引发异常。

{System.IO.FileNotFoundException: Could not load file or assembly 'xxx.Interfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'xxx.Interfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'

=== Pre-bind state information ===
LOG: User = xxx
LOG: DisplayName = xxx.Interfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///<myapp>/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: <myapp>\bin\Debug\Diagrammer.vshost.exe.Config
LOG: Using …
Run Code Online (Sandbox Code Playgroud)

.net c# reflection dll .net-assembly

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

如何使用 Web 应用程序/WebAPI 验证 Azure AD 中的用户凭据

我有一个网络应用程序。在主页中,用户将输入凭据,系统应根据 Azure AD 进行验证并继续进行。

当我使用本机应用程序并使用 时UserCredentials,它会验证用户,但如果我对 WebAPI 使用相同的方法,则会引发异常

请求正文必须包含以下参数:“client_secret 或 client_assertion”

当我使用 WebAPI using 时clientCredentials,它会生成 accessToken,它不会验证用户凭据。我还尝试在随后的调用中将凭据作为 httpclient 标头的一部分传递,尽管凭据错误,但它仍然有效。

string AzureADSTSURL = "https://login.windows.net/{0}/oauth2/token?api-version=1.0";
string GraphPrincipalId = "https://graph.windows.net";

string userid = "userid";
string password = "pass";

string tenantId = "axxx";   //  webapi
string clientId = "bxxx";
string clientSecret = "cxxx";
string authString = String.Format(AzureADSTSURL, tenantId);

var context = new AuthenticationContext(authString);

UserCredential userCredentials = new UserCredential(userid, password);
AuthenticationResult authenticationResult = context.AcquireToken(GraphPrincipalId.ToString(), clientId, userCredentials); // this works only if the …
Run Code Online (Sandbox Code Playgroud)

c# credentials azure asp.net-web-api azure-active-directory

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