Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Класс с функцией
- package foo;
- public class DiceRoller {
- //!!!ОЧЕНЬ ВАЖНО МЕТОД ДОЛЖЕН БЫТЬ СТАТИЧНЫЙ
- public static int rollDice() {
- return (int) ((Math.random() * 6) + 1);
- }
- }
- Tag Descriptor
- <?xml version=”1.0” encoding=”ISO-8859-1” ?>
- < taglib xmlns=”http://java.sun.com/xml/ns/j2ee”
- xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
- xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee/web-
- jsptaglibrary_2_0.xsd” version=”2.0”>
- <tlib-version>1.2</tlib-version>
- <uri>DiceFunctions</uri> //Выдумываем URI
- <function>
- <name>rollIt</name> //Выдумываем псевдоним функции
- <function-class>foo.DiceRoller</function-class> //Путь к классу
- <function-signature>
- int rollDice() //Название функции из класса
- </function-signature>
- </function>
- </taglib>
- JSP
- <%@ taglib prefix=”mine” uri=”DiceFunctions”%>
- <html><body>
- ${mine:rollIt()}
- </body></html>
Advertisement
Add Comment
Please, Sign In to add comment