1st question :
I generated a Jhipster application with the npm module (jhipster-generator).
The application run well.
I took a template file at random : for example settings.html
A part of the content is :
<h2>User settings for [<b>{{settingsAccount.login}}</b>]</h2>
I wish to replace it with a thymleaf i18n message like :
<h2 th:text="#{user.settings.for}">[<b>{{settingsAccount.login}}</b>]</h2>
So I added the key into both "messages_en" (and "messages_fr" I created) files ; located at src\main\resources\i18n\messages_xx.properties
So why, at displaying the settings page, the text is not displayed ? But only the angularjs variable is displayed :
<h2> [<b>{{settingsAccount.login}}</b>]</h2>
I tried to declare the th tag at index.html :
<html class="no-js" xmlns:th="http://www.thymeleaf.org">
but nothing happens.
2nd (subsidiary) question :
In addition, I noticed in the generated code that ThymleafConfiguration for spring boot specify a classpath resource bundle as :
messageSource.setBasename("classpath:/mails/messages/messages");
This classpath doesn't exist, but it is :
messageSource.setBasename("classpath:/mails/i18n/messages");
Despite of this mistake, It works anyway, I don't know why...
Thanks.
EDIT : I read the jhipster documentation for i18n at http://jhipster.github.io/installing-new-languages/ but thymleaf appears to be an alternative : for example mail creation exemple is based on thymleaf for i18n.
OK, angular-translate has to be installed at application generation for i18n.
I forgot thymeleaf, despite of I don't care i18n : I have only one language support that is not english.
Thanks.
Related
Please help me!
I can edit the URL of the page like "?key=value", then reload the page and see the result. But how to set params and reload when clicking on a tag?
<option value=""><a th:href="${'/?&sortByPrice=ASC'}">Giá từ thấp đến cao</a></option>
you put the wrong symbols in the URl.
you should use ? with the fist key/value and then use the &
Like this
/?sortByPrice=ASC&sortByvalue=none
OR
/abcd?sortByPrice=ASC&sortByvalue=none`
I'm trying to download a file from a specific directory everything works fine in the back-end when I test the service, but when I try it from the front-end I get this error and the pop/up save doesn't show.
Here's my back-end code with spring boot :
enter image description here
and my front with angular 5 looks like this
enter image description here
the service :
enter image description here
After your
respHeaders.setContentType(MediaType.APPLICATION_PDF);
Try adding this:
respHeaders.add("Content-Disposition", "attachment; filename=\"file.pdf\"");
I ve done some researches but couldn't find any question or answer that could help me,
so my probleme is as below :
I have a controller that redirects to an external link :
#controller("person")
publi class PersonController(){
#RequestMapping(value="redirect",method=RequestMethod.POST)
public String redirectToExternalLink(params...){
String url = "https://externalHost.com/doSomthing";
response.sendRedirect(url);
}
}
after going through this method, I find my self face to a 404 error Page not Found, when I check the link I ve been redrected to I find :
www.mydomainName.com/doSomthing
As you can see, the external domain name is replaced by mine, I ve tried also this :
response.setHeader("Location",url);
response.sendRedirect(url);
same issue.
is it a configuration that I should do on tomcat ? or there is a way to solve it ?
thanks
Your code
response.sendRedirect(url);
is correct. However, I would double check the url redirected to. I would also run the code in debug mode and check if
response.sendRedirect(url);
is executed in the first place.
Please refer to this question, Redirect to an external URL from controller action in Spring MVC.
If you encounter the common problem.
For my case, it was a network configurations issue (URL rewriting).
i have added sitemap.xml file to my codeigniter project.
And i call it on my localhost like that : http://localhost/demo/sitemap.xml
it runs without any issue.
But when i run it on live server http://example.com/demo/sitemap.xml
it says 404 page not found.
What is issue ?
you need to add below things in your config/routes.php file
$route['sitemap\.xml'] = 'demo/sitemap'; // your navigation path i.e. your controller_name/function_name
I'm new to web development stuff and have been looking at some ember, I wanted to try running this with Spring boot. I got spring boot working and was able to run the sample blog example created with ember.
Now I want to some data read from the spring server, for example I can go to http://localhost:8080/greeting?name=User and get the following displayed onto the page
{"id":12,"content":"Hello, User!"}
What I want to do is get ember to read make that call instead of me manually adding it in the url and getting ember to then display that data.
So in ember my app.js looks like this
App.IndexRoute = Ember.Route.extend({
model: function() {
return $.getJSON("http://localhost:8080/greeting?name=User");
}
});
This I believe makes the call. I was trying to re-display the data onto the onto the index.html like this:
<script type="text/x-handlebars" data-template-name="index">
<Not sure what to put here>
</script>
I may be missing something obvious or not getting something. I apologize if thats the case. Any help will be welcome
The model hook in your route should resolve to {"id":12,"content":"Hello, User!"}. Once that is resolved, Ember will populate the model property of the corresponding controller (in this case, IndexController, which is auto-generated if you don't provide one).
As the index template you are using is backed by that controller, you can refer to any of its properties, including model:
<script type="text/x-handlebars" data-template-name="index">
{{model.content}}
</script>
I hope you can make it work!