相关疑难解决方法(0)

如何创建与Thymeleaf和Spring一起使用的新表达式?


有人知道如何在百里香中扩展表达吗?(我在百里香中需要一个“品种”功能)。
克隆“数字”表达式是可行的,但是...
当我创建自己的表达式时,出现错误:

严重:路径为[]的Servlet [appServlet]的Servlet.service()抛出异常

  [Request processing failed;
   nested exception is   org.thymeleaf.exceptions.TemplateProcessingException: 
   Exception evaluating SpringEL expression:
   "Variety.Variety(review.usefulScore, 'osoba', 'osoby', 'osób')"
   (static:/cms/fragments/reviews:49)] with root cause
   org.springframework.expression.spel.SpelEvaluationException:
   EL1011E:(pos 8): Method call: 
  Attempted to call method  Variety(java.lang.Integer,java.lang.String,java.lang.String,java.lang.String) on null context object
Run Code Online (Sandbox Code Playgroud)

有什么建议么?

编辑(我的代码):包org.springframework.expression;

import org.springframework.expression.spel.support.StandardEvaluationContext;

public abstract class Variety extends StandardEvaluationContext {

    private boolean in_array(int needle, int[] haystack) {

        for(int i = 0; i < haystack.length; i++) {
            if(haystack[i] == needle) return true;
        }
        return false;
    }

    public String Variety(int number, String varietyFor1, …
Run Code Online (Sandbox Code Playgroud)

java spring thymeleaf

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

标签 统计

java ×1

spring ×1

thymeleaf ×1