Spring Thymeleaf expression is not working - thymeleaf

Can anyone please point out the problem i am facing while passing values through context to a templateEngine please.
<img th:src="${serverURL}/support-images/logo.jpg" height="54" width="108" alt=""></img>
"${serverURL}" : supposed to give me the complete URL where my application is hosted. The error i am getting is "Could not parse as expression: "${serverURL}/support-images/logo.jpg""
It make me realized something is wrong in the syntax but i could not follow the articles available. Can anyone please help!!
Thanks!!

You mix literals and expressions in your attribute. You should probably write <img th:src="${serverURL}+'/support-images/logo.jpg'" height="54" width="108" alt=""></img> for it to work better. See the examples in the documentation.
You may also want to read about the link URL feature in Thymeleaf (#{} notation) that can assist when building URLs.

Related

Where can I see the specification for thymeleaf th:method?

I've seen a lot of answers about how to send PUT/DELETE/PATCH HTTP requests with thymeleaf, and it's by using th:method = "the_specific_method", but i haven't found the thymeleaf specification about that. Can anyone help showing me where is it?
Thanks in advance.
I've tried to google for the answer, but no luck.
th:method isn't special to Thymeleaf -- it's just like any other plain old attribute which will output the result of an expression to the method attribute. It doesn't do (or care about) anything else. You can put any string and/or string expression into it, and Thymeleaf will happily output it.
th:method="${'the_specific_method'}"
will output
method="the_specific_method"
without regards to whether or not it's valid. If you want to learn about the method attribute, you just need to learn about how method works in plain old regular html and how browsers (and/or Spring) work with it.

Angular 2 - upload of file

I need to create upload of images to my webserver in my Angular 2 app. Can anybody provide me some guidance how to achive this?
These are the prerequisities:
ASMX web service communicating in JSON.
post method used for communication.
JPEG / PNG up to 1MB of size.
Concept I wanted to follow (but failed)
Load the content of JPEG to variable, encode it using the Base64 coding and post it to ASMX service that will accept two parameters (token for authentication and encoded data.
What exactly is my problem
Web service was the easy part, it is done and working, but I can't manage to get the file content for enconding. I used this:
component.html
...
<input type="file" (change)="fileChangeEvent($event)" />
...
component.ts
private fileChangeEvent(fileInput: any) {
let image = fileInput.target.files[0] as File;
...
}
As you have probably guessed, the problem is in the File class, because it provides me only basic info about the file (name, size, last modif, ...) but I can't get the content of the file. Or at least I don't know how to get it. I also checked other questions here on SO, but all of the answers had something special that did not met my requirements. And maybe I'm just blind, but I can't see where the content is get.
So, is there anybody, who is able to provide me some guidelines to follow?
Thank you very much in advance.
I have left this question open for experienced guys, who could be able to answer it. There is no answer though and I found out the answer yesterday. So, after some research and modification of search phrase, I found out the answer. There is a FileReader type which can be used for reading the content of the file. Here is the source of the answer:
Getting byte array through input type = file
Thanks to original answer now I know how to do it.

cawler: html file encodings issue

I try to write a crawler to get some information.But I find the word is different in webpage source.For example, the word Möller is Möller in html file.
I want to know how can I recover it after I get the html file.
Having fix this problem and provide the answer in case some beginner meet the same problem.
I use chr() to substitute the wrong code, for example use chr(246) to substitute ö
If there is better solution, please tell me.

How URL works? And what is the relation with GET and POST?

I have question, basic question I guess. But its important for me to learn more about web application.
I've ever seen a url with there are other words. for example:
http://api.openweathermap.org/data/2.5/weather?q=Setapak&mode=xml
there is q=setapak&mode=xml. what it means?
and what relationship with GET or POST?
when I try to create a simple page such which the code are:
<?lc
put $_GET['number'] into number
put number
?>
and I run the url on the browser: livecode/nana/url.lc?number=1
it shows nothing. So I get confuse. Can anyone explain to me?
Thank you..
Get will transfer you Parameter Using URL
all parameters will add to the URL ?number=1 this is one such example. it will carry number variable with value 1.
Post transfer parameters by attaching them to HTTP message body. Refer below link and you can get a good understanding about that.
http://www.w3schools.com/tags/ref_httpmethods.asp
You can't use single quotes in LC. use normal quotes around "number", and it should work.

BIRT Engine Integration In Struts2

I am integrating the BIRT Engine with Struts2 following this link http://birtworld.blogspot.com/2010/02/birt-and-struts-2.html at basic level it is ok.
But I am facing following issues...
Passing parameter to Task renderer...
task.setParameterValue("csvFilePath", req.getParameter("csvFilePath"));
this is thorwing an exception "The type of parameter "csvFilePath" is expected as
"string", not "[Ljava.lang.String;", I dont know what is mean by string here
please help in the context.
Drill down report has broken link.
I have two reports report1 and report2. report2 is not coming up when followed the hyperlink in report1.
The hyperlink seems to be broken, report has this hyperlink "http://localhost:8080/ReportEngineIntegration/run?__report=%2FE%3A%2FDashboardReportEngine%...". I wonder why this happening and why /run? is coming in the ulr.
Please help me in the context.
Thanks in advance
getParameter returns a string array. If a method takes a string, send only one string. (Making some assumptions about what req is here.)
That said, if you're using Struts 2, why are you accessing the request anyway?

Resources