How to tweak in jsp?

Is there a way of substring in JSP files using struts2 technology? I mean, struts2 has its own taglib, and also uses ognl. How to get substring from stacked value or bean value?

+3
source share
5 answers

http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/index.html

Find fn: a substring and its variants.

I used Struts 1, but not 2.

+3
source

Not.

If you need to analyze data (substring) in JSP, then you are probably mixing business logic (how it works) with your presentation logic (how it is displayed) - they should be separate. If you do a lot of conventions, calculations, parsing, etc. In your JSPs, then you create a lot of (future) pain for yourself.

- JSP , - , , , . Java, JSP, Java. , JSP "" Java-.

. Terence Parr http://www.cs.usfca.edu/~parrt/papers/mvc.templates.pdf. .

+1

Struts2 OGNL. , S2.

:

<s:property value="str.substring(0, 5)"/>
+1

, Websphere ! , Websphere 6.0 11, ( ). - , 13. JSP, - , , .

0
fn:substring(YOUR_FIELD, START_INDEX, END_INDEX)

, 3 , :

${fn:substring('scrooge', -1, 3)}

XML, , <% include% >

xmlns:fn="http://java.sun.com/jsp/jstl/functions"
0

Source: https://habr.com/ru/post/1696885/


All Articles