小编Joh*_*lla的帖子

Thymeleaf th:text - 放置文本而不删除HTML结构

我是百里香的新手,我尝试创建一个模板.我的问题是这段代码:

<h1 th:text="${header.title}" >
   title
   <small th:text="${header.subtitle}" >Subtitle</small>
</h1>
Run Code Online (Sandbox Code Playgroud)

我想得到这个输出:

<h1> TITLE <small> SUBTITLE</small> </h1>
Run Code Online (Sandbox Code Playgroud)

但这是真正的输出:

<h1> TITLE </h1>
Run Code Online (Sandbox Code Playgroud)

我怎么能这样做它不会删除"小"里面的东西?

提前致谢.

templates spring-mvc thymeleaf

47
推荐指数
3
解决办法
7万
查看次数

如何将字符插入NSString

如何向NSString插入空格.

我需要在索引5处添加一个空格:

NString * dir = @"abcdefghijklmno";
Run Code Online (Sandbox Code Playgroud)

要获得此结果:

abcde fghijklmno
Run Code Online (Sandbox Code Playgroud)

有:

NSLOG (@"%@", dir);
Run Code Online (Sandbox Code Playgroud)

objective-c nsstring ios5

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

使用AngularJS在输入中设置插入位置

我需要更改输入的插入位置,其中添加了给定的位数(示例).

app.controller('MainCtrl', function($scope, $element, $timeout, $filter) {
  //$scope.val = '12';
  $scope.$watch('val', function(newValue, oldValue) {
    if (!isNaN(newValue)) {
      if (newValue.length > 3) {
        //Set Caret Position  
      }
    }
  });
});
Run Code Online (Sandbox Code Playgroud)

有可能做这样的例子吗?

我需要例如:

输入:1234.

所以插入符号位置为2.

新数字:9

决赛:12934

提前致谢.

javascript angularjs angularjs-scope

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

选择Tag with Object - Thymeleaf和Spring MVC

我正在尝试更改此示例的代码thymeleafexamples-stsm,因此我更改了类类型的枚举类型:

Type.java

public class Type { 

    private Integer id; 
    private String type; 
   ...getters and setters 
}
Run Code Online (Sandbox Code Playgroud)

SeedStarterMngController.java

@ModelAttribute("allTypes") 
    public List<Type> populateTypes() { 
        Type type1 = new Type(); 
        type1.setId(1); 
        type1.setType("OUTDOOR"); 

        Type type2 = new Type(); 
        type2.setId(2); 
        type2.setType("INDOOR"); 

        List<Type> tipos = new ArrayList<Type>(); 
        tipos.add(type1); 
        tipos.add(type2); 
        return tipos; 
    } 
Run Code Online (Sandbox Code Playgroud)

seedstartermng.html

<select th:field="*{type}">
    <option th:each="type : ${allTypes}" th:value="${type}" th:text="${type.type}">Wireframe</option>
</select>
Run Code Online (Sandbox Code Playgroud)

所以,我不能添加种子入门.

我的输出html是

<select id="type" name="type">
    <option value="thymeleafexamples.stsm.business.entities.Type@2c08cec0">OUTDOOR</option>
    <option value="thymeleafexamples.stsm.business.entities.Type@26cf024">INDOOR</option>
</select>
Run Code Online (Sandbox Code Playgroud)

而错误是

无法将类型为java.lang.String的属性值转换为属性类型所需的类型thymeleafexamples.stsm.business.entities.Type; 嵌套异常是java.lang.IllegalStateException:无法将类型[java.lang.String]的值转换为属性类型所需的类型[thymeleafexamples.stsm.business.entities.Type]:找不到匹配的编辑器或转换策略

如何映射到正确键入?我希望你能帮助我.谢谢.

spring spring-mvc thymeleaf

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

Thymeleaf - 具有布局的碎片

我正在基于模板进行观察,但在某些方面我想要输入片段.

模板:base.html

<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
    <head>
        <title>HELLO</title>             
    </head>
    <body>
        <div layout:fragment="content"></div>
        <footer>
            Year Template
        </footer>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

查看:list.html

<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorator="base">
    <head th:replace="fragments/init :: head">
        <title>Title</title> 
    </head>
    <div  layout:fragment="content">
        <h1> <remove>List</remove> <small></small> </h1>       
    </div>
    <footer th:replace="fragments/init :: footer">
        Year List
    </footer>
</html>
Run Code Online (Sandbox Code Playgroud)

片段:fragment/init.html

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:th="http://www.thymeleaf.org">
<head th:fragment="head">
    <title>Title of Fragment</title>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/themes/smoothness/jquery-ui.css" />
    <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js"></script>
</head>
<body>
    <footer th:fragment="footer">
        2004 
    </footer>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

使用头部片段,它可以正常工作.但是在页脚中,但在页脚中,会显示模板的代码.

输出:

<html lang="en"><head>
    <title>Title of Fragment</title>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <link rel="stylesheet" …
Run Code Online (Sandbox Code Playgroud)

html5 thymeleaf

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

使用ajax和Play Framework 2发送Post Json

我有一个关于向播放控制器发送json数据的问题.

seach.scala.html

$.ajax({
            type :  "POST",
            dataType: 'json',
            data: {
                'filter': "John Portella"
            },
            url  :  "@routes.Search.findPag()",
            success: function(data){
                console.log(data);
            }
        });
        return false;
Run Code Online (Sandbox Code Playgroud)

控制器: POST /find/findPag Search.findPag()

public static Result findPag(){    
   JsonNode json = request().body().asJson();
   return ok();
}
Run Code Online (Sandbox Code Playgroud)

调试我得到json = null.你认为哪个可能是问题?谢谢.

javascript jquery playframework playframework-2.0

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

PriorityQueue 很慢

我正在实现一个数学函数,我需要一个优先级队列。我使用在此页面上找到的此代码:

class MyPriorityQueue(PriorityQueue):

    def __init__(self):
        PriorityQueue.__init__(self)
        self.counter = 0

    def put(self, item, priority):
        PriorityQueue.put(self, (priority, self.counter, item))
        self.counter += 1

    def get(self, *args, **kwargs):

        if self.counter == 0:
            return None

        _, _, item = PriorityQueue.get(self, *args, **kwargs)
        self.counter -= 1
        return item

    def empty(self):

        if self.counter == 0:
            return True

        return False
Run Code Online (Sandbox Code Playgroud)

众所周知python很慢,但是看到结果我意识到出队消耗了总执行时间的28%。有人有什么建议吗?

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
    34                                               @profile
    35                                               def solution(self):
    36                                           
    37         1           11     11.0      0.0          root = Node()
    38         1 …
Run Code Online (Sandbox Code Playgroud)

python queue performance priority-queue python-2.7

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

NSString发布

我有这个字符串代码,我在尝试释放内存时遇到问题,我了解到只有那些释放它的人才进行初始化,而不是自动释放,但是我遇到了字符串“ end”和nSum版本的问题。

NSString *urlBase = [[NSString alloc] initWithFormat:@"http://service.svc/"];
NSString *op = [[NSString alloc] initWithFormat:@"op1"];
NSString * final = [urlBase stringByAppendingFormat:op];
NSString * nSum = sumTextfield.text;
final = [final stringByAppendingFormat:nSum];

//release

[ urlBase release ];
[ op release ];
//[final release]; error
//[final autorelease]; error
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助。

更新:

- (IBAction)mostrarOpciones {
 // code (UP)
}
Run Code Online (Sandbox Code Playgroud)

release objective-c xcode4 ios5

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