[66] | 1 | <!-- |
---|
| 2 | Licensed to the Apache Software Foundation (ASF) under one or more |
---|
| 3 | contributor license agreements. See the NOTICE file distributed with |
---|
| 4 | this work for additional information regarding copyright ownership. |
---|
| 5 | The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
| 6 | (the "License"); you may not use this file except in compliance with |
---|
| 7 | the License. You may obtain a copy of the License at |
---|
| 8 | |
---|
| 9 | http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 10 | |
---|
| 11 | Unless required by applicable law or agreed to in writing, software |
---|
| 12 | distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 14 | See the License for the specific language governing permissions and |
---|
| 15 | limitations under the License. |
---|
| 16 | --> |
---|
| 17 | <html> |
---|
| 18 | <head> |
---|
| 19 | <title>JSP 2.0 Expression Language - Basic Arithmetic</title> |
---|
| 20 | </head> |
---|
| 21 | <body> |
---|
| 22 | <h1>JSP 2.0 Expression Language - Basic Arithmetic</h1> |
---|
| 23 | <hr> |
---|
| 24 | This example illustrates basic Expression Language arithmetic. |
---|
| 25 | Addition (+), subtraction (-), multiplication (*), division (/ or div), |
---|
| 26 | and modulus (% or mod) are all supported. Error conditions, like |
---|
| 27 | division by zero, are handled gracefully. |
---|
| 28 | <br> |
---|
| 29 | <blockquote> |
---|
| 30 | <code> |
---|
| 31 | <table border="1"> |
---|
| 32 | <thead> |
---|
| 33 | <td><b>EL Expression</b></td> |
---|
| 34 | <td><b>Result</b></td> |
---|
| 35 | </thead> |
---|
| 36 | <tr> |
---|
| 37 | <td>\${1}</td> |
---|
| 38 | <td>${1}</td> |
---|
| 39 | </tr> |
---|
| 40 | <tr> |
---|
| 41 | <td>\${1 + 2}</td> |
---|
| 42 | <td>${1 + 2}</td> |
---|
| 43 | </tr> |
---|
| 44 | <tr> |
---|
| 45 | <td>\${1.2 + 2.3}</td> |
---|
| 46 | <td>${1.2 + 2.3}</td> |
---|
| 47 | </tr> |
---|
| 48 | <tr> |
---|
| 49 | <td>\${1.2E4 + 1.4}</td> |
---|
| 50 | <td>${1.2E4 + 1.4}</td> |
---|
| 51 | </tr> |
---|
| 52 | <tr> |
---|
| 53 | <td>\${-4 - 2}</td> |
---|
| 54 | <td>${-4 - 2}</td> |
---|
| 55 | </tr> |
---|
| 56 | <tr> |
---|
| 57 | <td>\${21 * 2}</td> |
---|
| 58 | <td>${21 * 2}</td> |
---|
| 59 | </tr> |
---|
| 60 | <tr> |
---|
| 61 | <td>\${3/4}</td> |
---|
| 62 | <td>${3/4}</td> |
---|
| 63 | </tr> |
---|
| 64 | <tr> |
---|
| 65 | <td>\${3 div 4}</td> |
---|
| 66 | <td>${3 div 4}</td> |
---|
| 67 | </tr> |
---|
| 68 | <tr> |
---|
| 69 | <td>\${3/0}</td> |
---|
| 70 | <td>${3/0}</td> |
---|
| 71 | </tr> |
---|
| 72 | <tr> |
---|
| 73 | <td>\${10%4}</td> |
---|
| 74 | <td>${10%4}</td> |
---|
| 75 | </tr> |
---|
| 76 | <tr> |
---|
| 77 | <td>\${10 mod 4}</td> |
---|
| 78 | <td>${10 mod 4}</td> |
---|
| 79 | </tr> |
---|
| 80 | <tr> |
---|
| 81 | <td>\${(1==2) ? 3 : 4}</td> |
---|
| 82 | <td>${(1==2) ? 3 : 4}</td> |
---|
| 83 | </tr> |
---|
| 84 | </table> |
---|
| 85 | </code> |
---|
| 86 | </blockquote> |
---|
| 87 | </body> |
---|
| 88 | </html> |
---|