小编myb*_*dur的帖子

SpringMVC:将mediatype添加到要提供的静态资源

在我的spring-mvc应用程序中,我正在提供一些静态资源.JavaScrips,CSS和图像得到正确的服务,但也有一些json文件无法提供.

所以我在浏览器中可以看到这个文件: http:// localhost:8080/path/to/resources/example.png

但是这个文件(在同一个目录中)我没有收到: http:// localhost:8080/path/to/resources/example.json

我明白了:

DEBUG: org.springframework.web.servlet.resource.ResourceHttpRequestHandler - No media type found for ServletContext resource [/resources/path/to/resources/example.json] - returning 404
Run Code Online (Sandbox Code Playgroud)

所以我假设我需要在配置中添加这个mediatype扩展(.json),但我找不到它.

请帮忙!

spring-mvc staticresource

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

如何将工件安装到本地gradle文件存储中

谁能告诉我如何将工件/项目安装到本地gradle文件存储中?

gradle install
Run Code Online (Sandbox Code Playgroud)

将它安装到本地maven存储库但我需要将其安装到

~/.gradle/caches/artifacts-15/filestore
Run Code Online (Sandbox Code Playgroud)

gradle maven

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

“数据库'默认'处于不一致状态!” 来来去去

我有一个问题,即已部署服务器上的play数据库演进一次又一次处于不一致状态。我不明白这是什么问题。

  • 所有测试工作正常(在内存中)
  • 我可以通过运行启动应用程序(在内存中)
  • 我删除了进化sql-script并让它重新生成(通过在浏览器中单击进化触发器)
  • 我在conf文件中切换了用于mysql访问的必要属性
  • 我从开始构建 play clean compile stage
  • 我删除并创建mysql数据库
  • 然后我用-DapplyEvolutions.default = true启动应用程序

我经常得到这个错误:

[error] play - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'sequence life_cycle_event_seq' at line 1 [ERROR:1064, SQLSTATE:42000]
Oops, cannot start the server.
@6epm5i5m6: Database 'default' is in inconsistent state!
    at play.api.db.evolutions.Evolutions$.checkEvolutionsState(Evolutions.scala:177)
    at play.api.db.evolutions.Evolutions$.applyScript(Evolutions.scala:275)
    at play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$1$$anonfun$apply$1.apply$mcV$sp(Evolutions.scala:446)
    at play.api.db.evolutions.EvolutionsPlugin.withLock(Evolutions.scala:483)
    at play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$1.apply(Evolutions.scala:439)
    at play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$1.apply(Evolutions.scala:437)
    at scala.collection.immutable.List.foreach(List.scala:309)
    at play.api.db.evolutions.EvolutionsPlugin.onStart(Evolutions.scala:437)
    at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:63) …
Run Code Online (Sandbox Code Playgroud)

playframework playframework-2.1 playframework-evolutions

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

Scala函数需要Symbol/Any instate Array/Sequence

我应该使用一个函数作为scala函数参数.该函数如下所示:

def apply(field: Field, options: Seq[(String, String)], args: (Symbol, Any)*)(implicit handler: FieldConstructor, lang: Lang): Html 
Run Code Online (Sandbox Code Playgroud)

该args参数采用如下数组:

'_label -> "mylabel", '_showConstraints -> false, 'class -> "form-control"
Run Code Online (Sandbox Code Playgroud)

在play框架中,它看起来像这样:

@helper.select(myForm("fieldName"), options = options(MyObject.options), '_label -> "mylabel", '_showConstraints -> false, 'class -> "form-control")
Run Code Online (Sandbox Code Playgroud)

如何正确编写将项添加到数组的方法?像这样的东西:

@helper.select(callForm("callee"), options = options(LineDimension.options), args('_label -> "mylabel", '_showConstraints -> false, 'class -> "form-control"))
Run Code Online (Sandbox Code Playgroud)

功能:

@args(args: (Symbol, Any)*) = @{
    if (!filterEnabled) {
        args.add('disabled -> "disabled")
    }
    args
}
Run Code Online (Sandbox Code Playgroud)

播放控制台的错误消息是:

... type mismatch;
[error]  found   : Seq[(Symbol, Any)]
[error] …
Run Code Online (Sandbox Code Playgroud)

scala playframework

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

算法的改进:在字节数组中计数设置位

我们将字节数组中的知识存储为位.计算设置位数非常慢.欢迎任何改进算法的建议:

public static int countSetBits(byte[] array) {
    int setBits = 0;

    if (array != null) {
        for (int byteIndex = 0; byteIndex < array.length; byteIndex++) {
            for (int bitIndex = 0; bitIndex < 7; bitIndex++) {
                if (getBit(bitIndex, array[byteIndex])) {
                    setBits++;
                }
            }
        }
    }
    return setBits;
}
Run Code Online (Sandbox Code Playgroud)
public static boolean getBit(int index, final byte b) {
    byte t = setBit(index, (byte) 0);
    return (b & t) > 0;
}
Run Code Online (Sandbox Code Playgroud)
public static byte setBit(int index, final byte b) {
    return …
Run Code Online (Sandbox Code Playgroud)

java bit-manipulation

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