org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression

前言

本文中提到的解决方案,源码地址在:springboot-thymeleaf,希望可以帮你解决问题。

本文中涉及的两个异常为我开发时遇到的,可能和你目前所要处理的bug不同,如果不是同一个问题,希望再找找其他文章。

异常

Exception evaluating SpringEL expression这个异常的出现应该有很多原因引起,本文中涉及的两个异常分别为:

  • org.springframework.expression.spel.SpelEvaluationException: EL1004E: Method call: Method service() cannot be found on com.my.blog.springboot.thymeleaf.util.MethodTest type
  • org.springframework.expression.spel.SpelEvaluationException: EL1011E: Method call: Attempted to call method test() on null context object

解决方案

  • 异常1 :
Attempted to call method on null context object

调用的方法处于一个空对象中,即调用实例为空。

解决方案可以参考我的这篇文章:Method call: Attempted to call method test() on null context object

  • 异常2 :
Method cannot be found

方法不存在

解决方案可以参考我的这篇文章:Method service() cannot be found on com.my.blog.springboot.thymeleaf.util.MethodTest type

859549-20170915174624610-265059040.jpg

展开阅读全文

Evaluating Simple C Expressions

10-04

DescriptionnnThe task in this problem is to evaluate a sequence of simple C expressions, but you need not know C to solve the problem! Each of the expressions will appear on a line by itself and will contain no more than 80 characters. The expressions to be evaluated will contain only simple integer variables and a limited set of operators; there will be no constants in the expressions. There are 26 variables which may appear in our simple expressions, namely those with the names a through z (lower-case letters only). At the beginning of evaluation of each expression, these 26 variables will have the integer values 1 through 26, respectively (that is, a = 1, b = 2, ...). Each variable will appear at most once in an expression and many variables may not be used at all. nnThe operators that may appear in expressions include the binary (two-operand) + and -, with the usual interpretation. Thus the expression a + c - d + b has the value 2 (computed as 1 + 3 - 4 + 2). The only other operators that may appear in expressions are ++ and --. These are unary (one-operand) operators, and may appear before or after any variable. When the ++ operator appears before a variable, that variable's value is incremented (by one) before the variable's value is used in determining the value of the entire expression. Thus the value of the expression ++ c - b is 2, with c being incremented to 4 prior to evaluation the entire expression. When the ++ operator appears after a variable, that variable is incremented (again, by one) after its value is used to determine the value of the entire expression. Thus the value of the expression c ++ - b is 1, but c is incremented after the complete expression is evaluated; its value will still be 4. The -- operator can also be used before or after a variable to decrement (by one) the variable; its placement before or after the variable has the same significance as for the ++ operator. Thus the value of the expression -- c + b -- has the value 4, with variables b and c having the values 1 and 2 following the evaluation of the expression. nnHere's another, more algorithmic, approach to explaining the ++ and -- operators. We'll consider only the ++ operator, for brevity: nnIdentify each variable that has a ++ operator before it. Write a simple assignment statement that increments the value of each such variable, and remove the ++ from before that variable in the expression. nIn a similar manner, identify each variable that has a ++ operator after it. Write a simple assignment statement that increments the value of each of these, and remove the ++ operator from after that variable in the expression. nNow the expression has no ++ operators before or after any variables. Write the statement that evaluates the remaining expression after those statements written in step 1, and before those written in step 2. nExecute the statements generated in step 1, then those generated in step 3, and finally the one generated in step 2, in that order. nnUsing this approach, evaluating the expression ++ a + b ++ is equivalent to computing a = a + 1 (from step 1 of the algorithm) expression = a + b (from step 3) b = b + 1 (from step 2) where expression would receive the value of the complete expression.nInputnnYour program is to read expressions, one per line, until a totally blank (or empty) line is read. nBlanks are to be ignored in evaluating expressions, and you are assured that ambiguous expressions like a+++b (ambiguous because it could be treated as a++ + b or a + ++b) will not appear in the input. Likewise, ++ or -- operators will never appear both before and after a single variable. Thus expressions like ++a++ will not be in the input data.nOutputnnDisplay each expression exactly as it was read, then display the value of the entire expression, and on separate lines, the value of each variable after the expression was evaluated. Do not display the value of variables that were not used in the expression. The samples shown below illustrate the desired output format. nSample Inputnna + bnb - zna+b--+c++nc+f--+--an f-- + c-- + d-++enSample OutputnnExpression: a + bn value = 3n a = 1n b = 2nExpression: b - zn value = -24n b = 2n z = 26nExpression: a+b--+c++n value = 6n a = 1n b = 1n c = 4nExpression: c+f--+--an value = 9n a = 0n c = 3n f = 5nExpression: f-- + c-- + d-++en value = 7n c = 2n d = 4n e = 6n f = 5 问答

Expression

09-07

It is known that Sheffer stroke function (NOT-AND) can be used to construct any Boolean function. The truth table for this function is given below:nnTruth table for Sheffer stroke functionnnx y x|yn0 0 1n0 1 1n1 0 1n1 1 0nConsider the problem of adding two binary numbers A and B, each containing N bits. The individual bits of A and B are numbered from 0 (the least significant) to N-1 (the most significant). The sum of A and B can always be represented by N+1 bits. Let's call most significant bit of the sum (bit number N) the overflow bit.nnYour task is to construct a logical expression using the Sheffer stroke function that computes the value of the overflow bit for arbitrary values of A and B. Your expression shall be constructed according to the following rules:nnAi is an expression that denotes value of ith bit of number A.nBi is an expression that denotes value of ith bit of number B.n(x|y) is an expression that denotes the result of Sheffer stroke function for x and y, where x and y are expressions.nWhen writing the index, i, for bits in A and B, the index shall be written as a decimal number without leading zeros. For example, bit number 12 of A must be written as A12. The expression should be completely parenthesized (according to the 3rd rule). No blanks are allowed inside the expression.nnnInputnnThe input contains a single integer N (1 <= N <= 100).nnnOutputnnWrite to the output an expression for calculating overflow bit of the addition of two N-bit numbers A and B according to the rules given in the problem statement. nnNote: The stroke symbol ( | ) is an ASCII character with code 124 (decimal).nnThe output file shall not exceed 50*N bytes.nnnThis problem contains multiple test cases!nnThe first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.nnThe output format consists of N output blocks. There is a blank line between output blocks.nnSample Inputnn1nn2nnnSample Outputnn((A1|B1)|(((A0|B0)|(A0|B0))|((A1|A1)|(B1|B1)))) 问答

没有更多推荐了,返回首页