Lir

TLD EL JSP JAVA

Lir
Feb 29th, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. Класс с функцией
  2. package foo;
  3. public class DiceRoller {
  4.     //!!!ОЧЕНЬ ВАЖНО МЕТОД ДОЛЖЕН БЫТЬ СТАТИЧНЫЙ
  5.     public static int rollDice() {
  6.         return (int) ((Math.random() * 6) + 1);
  7.     }
  8. }
  9.  
  10. Tag Descriptor
  11. <?xml version=1.0” encoding=”ISO-8859-1?>
  12. < taglib xmlns=”http://java.sun.com/xml/ns/j2ee”
  13. xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
  14. xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee/web-
  15. jsptaglibrary_2_0.xsd” version=2.0>
  16.     <tlib-version>1.2</tlib-version>
  17.     <uri>DiceFunctions</uri> //Выдумываем URI
  18.     <function>
  19.         <name>rollIt</name> //Выдумываем псевдоним функции
  20.         <function-class>foo.DiceRoller</function-class> //Путь к классу
  21.         <function-signature>
  22.             int rollDice() //Название функции из класса
  23.         </function-signature>
  24.     </function>
  25. </taglib>
  26.  
  27. JSP
  28. <%@ taglib prefix=”mine” uri=”DiceFunctions”%>
  29. <html><body>
  30.     ${mine:rollIt()}
  31. </body></html>
Advertisement
Add Comment
Please, Sign In to add comment