thymeleaf使用附加属性data-*的方法

使用th:attr解决。

th:attr to the rescue Thymeleaf documentation – Setting attribute values.

For your scenario, this should do the job:

<div th:attr="data-el_id=${element.getId()}">

XML rules do not allow you to set an attribute twice in a tag, so you can’t have more than one th:attr in the same element.

Note: If you want more that one attribute, separate the different attributes by comma:如果想使用多个,方法如下

<div th:attr="data-id=${element.getId()},data-name=${element.getN‌​ame()}"> 

如果想拼接字符串。

If you need to include a variable as part of a string you need to do this: th:attr="data-id='some-text'+${element.getId()}+'some-other-‌​text',data-name=${el‌​ement.getName()}"


原地址:https://stackoverflow.com/questions/24411826/using-data-attribute-with-thymeleaf

PHP文件去掉utf8 bom

这个东西确实很烦,文件编码格式,各种情况 各种纠结,验证码一直不显示 找了几天 才发现是这个原因,最后网上找了一段代码才解决,下边是解决方法。

项目开始之初强调了utf8的编码,但居然还有no bom & bom 区分。痛苦啊!!
搞了个 kill utf8-bom 的php脚本,实现 convert utf-bom to utf8-nobom。

 

把以下代码保存为:killbom.php,放在要转换的文件根目录下执行即可。

**********************************************************************

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
if (isset($_GET['dir'])){ //config the basedir
    $basedir=$_GET['dir'];
}else{
    $basedir = '.';
}
$auto = 1;
checkdir($basedir);
function checkdir($basedir){
    if ($dh = opendir($basedir)) {
        while (($file = readdir($dh)) !== false) {
            if ($file != '.' && $file != '..'){
                if (!is_dir($basedir."/".$file)) {
                    echo "filename: $basedir/$file".checkBOM("$basedir/$file")."<br>";
                }else{
                    $dirname = $basedir."/".$file;
                    checkdir($dirname);
                }
            }
        }
    closedir($dh);
    }
}
function checkBOM ($filename) {
    global $auto;
    $contents = file_get_contents($filename);
    $charset[1] = substr($contents, 0, 1);
    $charset[2] = substr($contents, 1, 1);
    $charset[3] = substr($contents, 2, 1);
    if (ord($charset[1]) == 239 && ord($charset[2]) == 187 &&ord($charset[3]) == 191) {
        if ($auto == 1) {
            $rest = substr($contents, 3);
            rewrite ($filename, $rest);
            return ("<font color=red>BOM found,automatically removed.</font>");
        } else {
            return ("<font color=red>BOM found.</font>");
        }
    }
    else return ("BOM Not Found.");
}
function rewrite ($filename, $data) {
    $filenum = fopen($filename, "w");
    flock($filenum, LOCK_EX);
    fwrite($filenum, $data);
    fclose($filenum);
}
?>

ffmpeg录屏命令

ffmpeg -f gdigrab -framerate 24 -offset_x 100 -offset_y 100 -video_size 1000×580 -i desktop out.mpg
ffmpeg -f dshow  -i video=”UScreenCapture” -vf crop=1200:500:10:10 -r 30 -vcodec mpeg4 -q 12 out.mp4
ffmpeg -rtbufsize 1500M -f dshow  -i video=”UScreenCapture” -vf crop=1200:500:10:10 -r 30 -crf 0 -vcodec libx264 -q 12 out.mkv
ffmpeg -rtbufsize 1500M -f dshow -r 24 -i video=”UScreenCapture” -vf crop=1200:500:10:10 -crf 0 -vcodec mpeg4 -x264opts keyint=1   out.mp4
ffmpeg -rtbufsize 1500M -f dshow -i video=UScreenCapture -vcodec h264 -r 15  -q 12 -pix_fmt yuv420p -vf crop=1200:800:10:10 out.flv
ffmpeg -rtbufsize 1500M -f dshow -i video=”UScreenCapture” -vcodec libx264 -crf 0 -preset ultrafast output.flv
ffmpeg -f gdigrab -framerate 16 -offset_x 100 -offset_y 100 -video_size 1000×580 -i desktop  -vcodec h264   -q 12 -pix_fmt yuv420p out.flv
ffmpeg -rtbufsize 1500M -f dshow -i audio=”virtual-audio-capturer” -f gdigrab -framerate 30 -draw_mouse 1 -i title=RecordWindow -pix_fmt yuv420p -profile:v baseline -y test.mp4

vs2015编译ffmpeg无法解析外部符号__imp__fprintf解决方法

使用vs2015编译ffmpeg的一个小项时,出现了__imp__fprintf和__imp____iob_func 的错误,google了一下,有的人 建议下载SDL源码重新编译一下,当然这个方案非常不科学。所以又继续搜,终于有所发现。

这是老外的原话:

In visual studio 2015, stdin, stderr, stdout are defined as follow :

#define stdin  (__acrt_iob_func(0))
#define stdout (__acrt_iob_func(1))
#define stderr (__acrt_iob_func(2))

But previously, they were defined as:

#define stdin  (&__iob_func()[0])
#define stdout (&__iob_func()[1])
#define stderr (&__iob_func()[2])

So now __iob_func is not defined anymore which leads to a link error when using a .lib file compiled with previous versions of visual studio.

To solve the issue, you can try defining __iob_func() yourself which should return an array containing {*stdin,*stdout,*stderr}.

Regarding the other link errors about stdio functions (in my case it was sprintf()), you can add legacy_stdio_definitions.lib to your linker options.

答题意思就是stdin, stderr, stdout 这几个函数vs2015和以前的定义得不一样,所以报错。

解决方法呢,就是使用{*stdin,*stdout,*stderr}数组自己定义__iob_func()

其实就是下边这样。

extern "C" { FILE __iob_func[3] = { *stdin,*stdout,*stderr }; }

然后__imp__fprintf的解决方法就是在链接器输入lib里加上legacy_stdio_definitions.lib这个LIB