小编tho*_*vdb的帖子

Hibernate序列不存在

我尝试在Spring项目的项目中将hibernate从4升级到5 4.2.升级完成后,当我调用更新方法时,我在堆栈跟踪中发现以下错误.

10:53:32,185 ERROR TableStructure:149 - could not read a hi value
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'test.hibernate_sequence' doesn't exist 
Run Code Online (Sandbox Code Playgroud)

我用注释更改了自动递增的Id

@GeneratedValue(strategy=GenerationType.AUTO) 
Run Code Online (Sandbox Code Playgroud)

仍然是错误.

java spring hibernate

82
推荐指数
9
解决办法
9万
查看次数

淘汰赛 - 获得点击的元素

我有以下标记:

<fieldset>
   <div>
       <label class="editor-label">Question 1?</label>
       <input type="text" class="editor-field" />     
       <button type="button" data-bind="click: helpClicked">Help</button>
       <p class="help">Help 3</p>
   </div>
    <div>
       <label class="editor-label">Question 2?</label>
       <input type="text" class="editor-field" />
       <button type="button" data-bind="click: helpClicked">Help</button>
       <p class="help">Help 3</p>
   </div>
   <div>
       <label class="editor-label">Question 3?</label>
       <input type="text" class="editor-field" />
        <button type="button" data-bind="click: helpClicked">Help</button>
       <p class="help">Help 3</p>
   </div>
</fieldset>
Run Code Online (Sandbox Code Playgroud)

我想切换<p>与类的可见性,与单击的按钮help相同Div.我试图使用$(this)来确定单击了哪个按钮然后我可以从那里获得正确的"帮助"元素.

问题是$(this)没有返回单击的按钮.

目前我试图简单地隐藏点击的按钮,如:

var viewModel = {
    helpClicked: function () {
        $(this).hide();           
    }
};

ko.applyBindings(viewModel);
Run Code Online (Sandbox Code Playgroud)

这不起作用.有人可以帮忙吗?

javascript jquery knockout.js

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

Url.Action如何运作Asp.net MVC?

这与我提出的另一个问题有些相关,但我想为什么不单独问它.

如果我在视图中放置类似下面的内容

<td><img src='<%= Url.Action( "DisplayImage" , "User" , new { id = item.id} ) %>' alt="" /></td>
Run Code Online (Sandbox Code Playgroud)

它应该显示这个吗?

<td>
   <img src='/User.mvc/DisplayImage?id=U00915441' alt="" />
</td>
Run Code Online (Sandbox Code Playgroud)

或者,src属性的值实际上是否会被UserController GetImage Action的结果替换?

asp.net asp.net-mvc helper url.action

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

关闭 SQL 连接但打开的连接不断增加

我有以下方法:

public DataSet GetDataSet( string sp, params SqlParameter[] parameters ) {
DataSet ds = new DataSet();

using ( SqlConnection conn = new SqlConnection(
        ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString
    ) ) {
    using ( SqlCommand cmd = new SqlCommand() ) {
        cmd.Connection = conn;
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = sp;

        if ( parameters != null ) {
            foreach ( SqlParameter parm in parameters ) {
                cmd.Parameters.Add( parm );
            }
        }

        if ( conn.State == ConnectionState.Closed ) {
            conn.Open();
        }

        using ( SqlDataAdapter da = new …
Run Code Online (Sandbox Code Playgroud)

c# sql-server asp.net ado.net

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

VirtualPathProvider性能

我目前正在尝试创建一个类库并将MVC视图嵌入其中,以便我们可以在多个站点上共享它,如下所述:http://www.wynia.org/wordpress/2008/12/aspnet-mvc-plugins /

性能很重要,所以我想弄清楚这是否可行.如果可能的话,有人可以稍微解释一下VirtualPathProvider吗?

我注意到这个方法只为每个文件调用一次.

public override VirtualFile GetFile(string virtualPath)
{
    if (ResourceFileExists(virtualPath))
         return new EmbeddedVirtualFile(virtualPath);

    return base.GetFile(virtualPath);
}
Run Code Online (Sandbox Code Playgroud)

VirtualPathProvider是否自动缓存文件/视图?在另一篇文章中(解释相同的事情),他们声明你应该覆盖GetCacheDependency:

public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
{
    if (ResourceFileExists(virtualPath))
        // Return null or otherwise ASP.NET will try to monitor the file.
        // Is actually the default implementation.
        return null;

    return base.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart);
}
Run Code Online (Sandbox Code Playgroud)

所以在这里返回null不会影响VirtualFile的"缓存"?我问这个的原因是因为我们创建的VirtualFile的自定义实现,称为EmbeddedVirtualFile,在重写的Open()方法中使用了这段代码:

var assembly = Assembly.LoadFile(assemblyName);
if (assembly != null)
{
    Stream resourceStream = assembly.GetManifestResourceStream(resourceName);
    return resourceStream;
}
Run Code Online (Sandbox Code Playgroud)

我有点害怕这会有性能损失.有人可以安慰我吗?

c# asp.net-mvc virtualpathprovider

5
推荐指数
0
解决办法
1333
查看次数

如何在数据库中的IdentityServer4中添加新客户端?

在最初的测试中,我始终AddInMemoryClients按照其文档中所述使用IdentityServer4 的配置。

但是,我正在将其部署到我们的测试环境中,并且想要摆脱配置文件,因此我设置了Entity Framework集成

现在,所有客户端ID,客户端机密,作用域……都以加密方式保留在数据库中。但是,添加新客户端更加困难。

什么是适当的配置方式?

使用实体框架迁移?

我知道IdentityServer4上有一个UI,但这是唯一的“简便”方法吗?

identityserver4

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

获取ASP.NET控件,该控件在AJAX UpdatePanel中触发回发

与此问题相关:在回发时,如何检查哪个控件导致Page_Init事件中的回发

如果控件包装在ASP.NET AJAX UpdatePanel中,则变量"control"为空,因为它在AJAX PostBack之后具有不同的ID.是否有解决方案来获取在ASP.NET Ajax UpdatePanel中触发回发的控件?

public static string GetPostBackControlName( Page page ) {
        Control control = null;

        /**
         * First we will check the "__EVENTTARGET" because if the postback is made
         * by controls which used the _doPostBack function, it will be available in the Request.Form collection.
         */
        string ctrlname = page.Request.Params["__EVENTTARGET"];

        if ( !String.IsNullOrEmpty( ctrlname ) ) {
            control = page.FindControl( ctrlname );
        } else {
            /**
             * If __EVENTTARGER is null, the control is a …
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-ajax

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

Knockout - 根据observableArray检查复选框

所以我有一个我需要为用户显示的时间表列表,并显示他或她当前正在进行的时间表,并让他们可以跳过和关闭所述时间表.

我的viewmodel看起来像这样

self = this;
self.shifts = ko.observableArray();
self.selectedShifts = ko.observableArray();

//I populate self.shifts here with a WEB API call

//Run through each shift and check if current user is on it and set checked / not checked    value for checkbox
        ko.utils.arrayForEach(self.shifts(), function(shift) {

           //Clear array
            self.usersOnShift([]);

            //Populate array with all users on the shift
            self.usersOnShift = ko.observableArray(WEB API CALL HERE);

            var userInShift = ko.utils.arrayFirst(self.usersOnShift(), function(user) {
                if (selectedUserId == user.ID) {
                    return true;
                } 
            });

            if (userInShift) {

                self.selectedShifts.push(shift.ID); …
Run Code Online (Sandbox Code Playgroud)

html javascript data-binding checkbox knockout.js

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