我正在尝试使用C++在Linux中编写一个小型音乐管理器.我目前正在使用TagLib来读取媒体的元数据.但是,据我所知,TagLib不支持从视频中读取标签(标题,艺术家等).因此,我只想问你们,是否有任何其他库可以用来阅读视频文件的标签(标题,艺术家等等)?
谢谢你回答我的问题!你们这周过得愉快!
我想将此函数导出到我的custom-functions.tld文件中:
package com.site.vo;
public class Utils {
public static String concat(String... values) {
String out = "";
for (String value : values) {
out.concat(value);
}
return out;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的custom-functions-tld档案:
<?xml version="1.0" encoding="UTF-8"?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
<tlib-version>2.0</tlib-version>
<uri>/WEB-INF/custom-functions.tld</uri>
<function>
<description>Concatenate strings</description>
<name>concat</name>
<function-class>com.site.vo.Utils</function-class>
<function-signature>java.lang.String concat(java.lang.String...)</function-signature>
</function>
</taglib>
Run Code Online (Sandbox Code Playgroud)
这function-signature没用,我得到了以下例外:
org.apache.jasper.JasperException: The class java.lang.String... specified in the method signature in TLD for the function f:concat cannot be found. java.lang.String...
尝试过java.lang.String[],但那个只需要一个参数(一个列表,给我哦!).我正在寻找正确的函数签名来导出具有多个参数的函数.
先感谢您!
我有一个我编写的自定义标记库,以便我可以轻松地显示对象的属性.它允许我打电话
<g:property label="Name" property="${user.name}"/>
Run Code Online (Sandbox Code Playgroud)
这使我的观点简短而一致,并允许我快速进行更改.我的taglib代码如下:
def property = {attrs, body ->
def startingHtml = "..."
def endingHtml = "..."
out << startingHtml
renderField(attrs.property)
out << endingHtml
}
def renderField(property) {
if (property instanceof Collection) {
property.each { out << it + "</br>" }
} else if(property instanceof Address){
renderAddress(property)
} else {
out << property
}
}
def renderAddress(address) {
out << "Address Render Logic Here"
}
Run Code Online (Sandbox Code Playgroud)
我试图在这段代码中添加一些单元测试,因为它有逻辑.使用此处的示例(http://grails.org/doc/latest/guide/testing.html#unitTestingTagLibraries),我开始添加一些测试.我的标签当前处理的前两个场景是String和Collection,我能够正确测试(下面的前两个测试).我需要测试的最后一个场景是Address对象(它只是一个带有String属性的POGO).我似乎无法找到一种方法来测试将对象作为属性传递到标记lib中.
@TestFor(PropertyTagLib)
class PropertyTagLibTests {
@Test
void propertyTagShouldRenderPropertyInsideOfTDWhenPropertyIsAString() {
String result …Run Code Online (Sandbox Code Playgroud) 在HTML中我们可以写
<select name="..." value"...">
<optgroup label="Category 1">
<option ... />
<option ... />
</optgroup>
<optgroup label="Category 2">
<option ... />
<option ... />
</optgroup>
</select>
Run Code Online (Sandbox Code Playgroud)
在Spring <form>标签中,我们如何编写类似于组项的东西.
我正在使用表单标签.
<form:form commandName="foo">
<div class="myclass ">
<label>Foo</label>
<form:input path="fooName"/>
</div>
<div class="controls">
<input type="submit" class="btn" value="Submit"/>
</div>
</form:form>
Run Code Online (Sandbox Code Playgroud)
题
有没有办法找出特定字段上是否发生错误?
我知道<form:erros path="fooName"/>但这会打印出错误信息.我根据fooName属性是否发生错误而返回true或false .我需要这个,因为如果错误发生,那么我可以在error旁边插入css类my class
我正在尝试使用grails标签库.我创建了一个名为isowner的简单标记库
class AuthTagLib {
static defaultEncodeAs = 'html'
def springSecurityService
def isOwner = { attrs, body ->
def loggedInUser = springSecurityService.currentUser
def owner = attrs?.owner
if(loggedInUser?.id == owner?.id) {
out << body()
}
}}
Run Code Online (Sandbox Code Playgroud)
然后尝试将其与gsp一起使用:
<g:isOwner owner="${leaveFormInstance.employee}">
<g:link class="edit" action="edit" resource="${leaveFormInstance}">
<g:message code="default.button.edit.label" default="Edit" />
</g:link>
</g:isOwner>
Run Code Online (Sandbox Code Playgroud)
现在它应该将用户对象作为输入并验证用户是否是帖子的所有者.
现在一切正常但在输出html中它将链接显示为文本.

我对这些东西很新,必须缺少一些基础知识,你能帮忙吗?
我正在使用grails 2的权威指南(使用grails 2.3.7)学习grails,当我查看自定义标记库时,它给出了一个示例自定义标记,如下所示:
def repeat = { attrs, body ->
int n = attrs.int('times)
n?.times { counter ->
out << body(counter +1)
}
}
Run Code Online (Sandbox Code Playgroud)
所以当我像这样使用这个标签时:
<g:repeat times="3">
Hello number ${it}<br>
</g:repeat>
Run Code Online (Sandbox Code Playgroud)
我期望在我呈现的HTML上获得三个单独的行:
Hello number 1
Hello number 2
Hello number 3
Run Code Online (Sandbox Code Playgroud)
相反,我得到:
hello number 1<br>hello number 2<br>hello number 3<br>
Run Code Online (Sandbox Code Playgroud)
我找到了看起来应该有帮助的方法,比如decodeHTML()但是我因此无法改变我想要的输出,而且我不确定我做错了什么.
我试过做:
out <<body.decodeHTML()
Run Code Online (Sandbox Code Playgroud)
但我得到一个空指针错误...
我有一个 mp3 文件,我想向其中添加专辑封面。艺术作品已保存到临时文件夹中,我已检查过它,它就在那里并且是 jpeg。这是我给出的代码:
public void AddMp3Tags()
{
TagLib.File file = TagLib.File.Create(OutputPath + OutputName + "." + Format);
SetAlbumArt(Art, file);
file.Tag.Title = SongTitle;
file.Tag.Performers = Artists.Split(',');
file.Tag.Album = Album;
file.Tag.Track = (uint)TrackNumber;
file.Tag.Year = (uint)Convert.ToInt32(Regex.Match(Year, @"(\d)(\d)(\d)(\d)").Value);
file.Save();
}
public void SetAlbumArt(string url, TagLib.File file)
{
string path = string.Format(@"{0}temp\{1}.jpg", OutputPath, Guid.NewGuid().ToString());
using (WebClient client = new WebClient())
{
client.DownloadFile(new Uri(url), path);
}
TagLib.Picture pic = new TagLib.Picture
{
Type = TagLib.PictureType.FrontCover,
Description = "Cover",
MimeType = System.Net.Mime.MediaTypeNames.Image.Jpeg
};
MemoryStream ms …Run Code Online (Sandbox Code Playgroud) 我写了一个Grails标签,它只是围绕Grails select标签的一个非常薄的包装器
package com.example
class MyTagLib {
def listTrees = {attrs ->
List<TreeDto> allTrees = getMandatoryAttributeValue(attrs, 'trees')
out << g.select(from: allTrees)
}
}
Run Code Online (Sandbox Code Playgroud)
我已经为这个类进行了单元测试,但是当我运行它时,在执行最后一行时出现以下错误:
groovy.lang.MissingMethodException:没有方法签名:com.example.MyTagLib.select()适用于参数类型:(java.util.LinkedHashMap)
g在运行单元测试时,似乎无法使用命名空间中grails标记的引用.我尝试过创建集成测试,但这也不起作用.
有没有办法测试一个调用另一个标签的标签,而无需对其他标签的输出进行存根/模拟?
我想制作一个util方法,从地图转换为列表,以便与EL一起使用,这是我试过的:
1- utils.taglib.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE facelet-taglib PUBLIC
"-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
"https://facelets.dev.java.net/source/browse/*checkout*/facelets/src/etc/facelet-taglib_1_0.dtd">
<facelet-taglib xmlns="http://java.sun.com/JSF/Facelet">
<namespace>http://mycomp.com/utils</namespace>
<function>
<function-name>mapToList</function-name>
<function-class>com.mycomp.MyClass</function-class>
<function-signature>java.util.List mapToList(java.util.Map)</function-signature>
</function>
</facelet-taglib>
Run Code Online (Sandbox Code Playgroud)
2- web.xml:我添加了它,因为我添加了spring安全标记lib,如下所示:
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>
/WEB-INF/springsecurity.taglib.xml
/WEB-INF/utils.taglib.xml
</param-value>
</context-param>
Run Code Online (Sandbox Code Playgroud)
3- xhtml页面:
xmlns:utils="http://mycomp.com/utils"
<ui:repeat value="#{utils:mapToList(myBean.map)}" var="entry" >
Key = #{entry.key} Value = #{entry.value} <br/>
</ui:repeat>
Run Code Online (Sandbox Code Playgroud)
4- Util类:
public class MyClass{
public static <T, S> List<Map.Entry<T, S>> mapToList(Map<T, S> map) {
if (map == null) {
return null;
}
List<Map.Entry<T, S>> list …Run Code Online (Sandbox Code Playgroud)