how to add new line in thymeleaf between two strings in java? - html

I'm beginner in Thymeleaf.
I want to add br tag in between two strings
in html
Ex:
I want to add break tag in between ${student[0] and ${student[1].
${student[1] data should come to the next line.
th:text="|${student[0]} br ${student[1]}|"
.Can anyone help me? Any comments would be appreciate Thanks in advance....

You can use th:utext to output html, like this
th:utext="|${student[0]} <br /> ${student[1]}|"
That said, I would stay away from that if possible and just add it as regular html, like this for example:
<span th:text="${student[0]}">
<br />
<span th:text="${student[1]}">

Related

With BeautifulSoup, can I get texts with other strings between tags to seprate among those?

So, I've working on crawling with BeautifulSoup, but I've encountered some messy html tags.
This is an example for that:
<html>
<body>
<p>Hey</p>
<div>
<div>
<span class="date">0817</span>
</div>
</div>
<p>I want all of those</p>
<div>
<div>
<p>But I want to get those separately</p>
<div>
</div>
<p>Hope this work</p>
</body>
</html>
So if I use code like this:
soup = BeautifulSoup(html,'html.parser')
body = soup.find("body")
print(body.text)
I'll probably get this:
"Hey0817I want all of thoseBut I want to get those separatelyHope this work"
The question is, can I get those texts with some strings as a separators? Separators to separate things between other tags Like:
"###Hey###0817###Iwant all of those###But I want to get those separately###Hope this work"
or
"Hey###0817###Iwant all of those###But I want to get those separately###Hope this work###"
or
"Hey###0817###Iwant all of those###But I want to get those separately###Hope this work"
So that I can sperate those texts by those "###" later with other codes?
Or is there any walkaround doing similar things?
Any advice would be greatly helpful. Thanks for your kind interest and times!
Hope you can enlighten me.
If you want a list, you can use:
item_text = [t.text for t in body.find_all()]
if you really want the separators:
body.get_text('###')
I will use .get_text:
soup.body.get_text('###')
A strip will be better:
soup.body.get_text('###').strip()
You can get the newlines expanded too:
print(soup.body.get_text('###').strip())

How do you write <p></p> and display it on your site?

How do you write <p></p> so that it can be displayed as text in an HTML page, rather than be interpreted as HTML (which would give an empty paragraph).
If you want to show the in the view,
Because, when you type that inside html element, it may be getting it as the html element itself.
if your purpose is showing that in the view just try this.
&ltp> &lt/p>
Check this snippet :
&ltp> &lt/p>
you can do it with using span
<span> < </span> <span>p</span> > <span> < </span> / <span>p</span><span> > </span>
or you can do below like this
<p> </p>
A P tag should print out text on your site no matter what. However, on most occasions you will need to refresh (F5) your page in order for it to take effect. Furthermore, if you got anything on your site that could be covering it up, try removing it just to see whether another element is "eating it up" or not. For example, try removing a banner image if thats something you got, or a navbar.
Usage for P, just in case:
<p> Text goes here </p>
Use Html entities to display the reserved html symbol
HTML Entities
this is what you mean? sorry if i understand wrongly but your description is very short.
View the source of this page. It managed it!
<p><\p>
and the answer was <p><\p>

The correct syntax of new line in html

I have seen so many different ways to break row in html.
I'm using <br /> and it works fine.
What is the correct use of <br /> as for now?
<br> is correct way to implement for line break if you are using for address and paragraph purpose.

HTML tags with spaces

so I have a strange request. I've been working on some security project for school, and I've been able to successfully inject some html code using a form on our test site. What's interesting is that it only accepts the html code as one line and with no spaces. This brings me to my question, so far I've only been able to get text and font color changes to work. But I want to see if someone could inject images/audio/video.
I'm trying to figure out how to turn this:
<img src="http://www.rtur.net/blog/image.axd?picture=2011%2F12%2Fcss.png"/>
Into this:
<imgsrc="http://www.rtur.net/blog/image.axd?picture=2011%2F12%2Fcss.png"/>
but add a space with code.
I've tried adding the but that only works with actualy text and not the tag itself. Any help is appreciated.
Interesting note: I was able to inject <font size="50" color="red"></font>
But I have no idea why that works but the image doesn't.
Have you tried the following?
A slash:
<img\ src="http://www.rtur.net/blog/image.axd?picture=2011%2F12%2Fcss.png"/>
Using a non-traditional closing tag:
<img src="http://www.rtur.net/blog/image.axd?picture=2011%2F12%2Fcss.png"></img>
Injecting a blank <img> tag:
<img src=""/>
Here's another solution: Try inline CSS:
<div style="background:url(http://www.rtur.net/blog/image.axd?picture=2011%2F12%2Fcss.png);height:400px;width:400px"></div>
See this fiddle: http://jsfiddle.net/9MYrM/

How to ignore the content of a <span> within a <h3> element using XPATH?

I have the following markup:
<h3 class="foo">I WANT THIS <span class="bar">I DON'T WANT THIS</span></h3>
Is there any way to get ignore the content of the <span> with XPATH? So far all efforts have been fruitless. Seems easy, but I can't for the life of me figure this out...
Just to be crystal clear - the result should be:
I WANT THIS
In his case text() should help.
Try //h3/text() (at least for xapth-1.0 I'm not sure if this will work with 2.0).