Downloaded image dont show it in maven project - image

I have a maven project and i download images dinamicly in folder \src\main\webapp\images\, but dont show it in browser. Example:
|- src
|- main
|- java
|- resources
|- webapps
|- images
|- image1.jpg (fixed)
|- image2.jpg (fixed)
|- image3.jpg (downloaded with my app)
If i show image1.jpg or image2.jpg works perfecty, but if i try show image3.jpg dont works:
<img src="images/image1.jpg" /> <!-- Works -->
<img src="images/image2.jpg" /> <!-- Works -->
<img src="images/image3.jpg" /> <!-- Not Works -->
Any idea?
Thanks.

Well... as far as I understand your are modifying your web-app resources at runtime. It works fine in eclipse because eclipse do kind of hot-deployement when your workspace is modified (i.e. when a new file is added in your webapp dir it is automatically available as a webresource for your appserver).
I don't think it's a good design. Imagine you download one image, then redeploy your webapp: the downloaded image will be lost.
Instead of putting your downloaded images in your web app resources: put them somewhere else (outside the war hierarchy, maybe in a directory managed by your web server)

Related

Location to add view files: SPRING MVC

In SPRING MVC project, Which is the right folder location to create a new JSP(view) file:
WebContent\new_jsp_file.jsp
or
Java Resources\src\com.example.view\new_jsp_file.jsp
Note: com.example.view is a manually created package
Usually JSP file is located here:
%projectfolder%/src/main/webapp/WEB-INF/jsp/
JSP files should be put inside WEB-INF directory, because contents of WEB-INF aren't directly accessible by users, which is needed for application security.
If you are using Maven or Gradle:
project-name
|- src
|- main
|- java
|- resources
|- webapp
|- WEB-INF
|--- put JSPs here, can create subdirectories if needed

Xamarin and Shared Project - Can't display an Image

my solution is structured like this:
- MyApp.Shared (Shared Project)
|- myPage.xaml
- MyApp.Android (Android Project)
|- Resources
|- drawable
|- img-1.png (BuildAction: AndroidResource, Do not Copy)
- MyApp.iOS (iOS Project)
|- Resources
|- img-1.png (BuildAction: BundleResource, Do Not Copy)
And in my xaml page (in the shared project) i've this simple piece of code:
<Image Aspect="AspectFit" Source="img-1.png">
Why i can't see image (in the droid and ios app)
I followed the Xamarin Tutorial
Using dashes in the name of the resource brokes the regeneration of Resource.Designer.cs
The name given was img-1.png: I renamed it to img1.png and it works

Change Spring-boot static web resources location?

Base on this tutorial:
http://spring.io/guides/gs/serving-web-content/
I can use the thymeleaf to serve the view in the location
/src/main/resources/templates/
However, I have to put the static web contents (css, js) in another location:
/src/main/webapp/resources
And linking the resources in the hello.html like that:
<link href="resources/hello.css" />
<script src="resources/hello.js"></script>
The directory structure is:
└── src
└── main
└── java
└── hello.java
└──resources
└──templates
└──hello.html
└──webapp
└──resources
└──hello.js
└──hello.css
The problem is that the links of the static files are work when I run the web server. But if I open the html files in offline mode, the links are broken.
Could I move the static resource from
/src/main/webapp/resources
to:
/src/main/resources/templates/resources
The new directory structure would be like:
└── src
└── main
└── java
└── hello.java
└──resources
└──templates
└──hello.html
└──resources
└──hello.js
└──hello.css
I tried it but is doesn't work.
Try src/main/resources/static (or src/main/resources/public or src/main/resources/resources). All those are registered by Spring Boot autoconfig.
Define the mapping in your context like following -
<mvc:resources mapping="/templates/**"
location="classpath:/templates/" />
This will route everything that's hitting /template/ url to search for contents under your src/main/resources/templates/ folder.
In case you need tweaking in the url/prefix - adjust the mapping accordingly.

Create java resources webapp folder structure with maven

I want to create /java, /resources, and /webapp/WEB-INF/web.xml folder structure under src.
I have used the -DarchetypeArtifactId=maven-archetype-webapp but it creates /resources /webapp/WEB-INF/web.xml but doesn't create /java folder.
So in spite of creating the folder /java in eclipse manually is there any other way to create with some -DarchetypeArtifactId= so that it creates the above folder structure.
I'll be thankful if someone can tell me how can I customize and design my folder structure and create it with maven without using existing template.
When you use -DarchetypeArtifactId=maven-archetype-webapp, java folder wont be created. It needs to be created manually.
It created the following structure
src
└── main
└── resources
└── webapp
└── WEB-INF
Best choice is to follow Maven standard directory layout:
http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
Archetypes are minimized due different programming languages can be used for web development:
http://cvs.peopleware.be/training/maven/maven2/standardDirLayout.html (link goes to web.archive since the main link is dead)
It will minimize configuration of plugins and also will simplify understanding and maintenance of Maven projects
you can create a Maven Webapp using following archetype
-DarchetypeArtifactId=maven-archetype-webapp
which will automatically creates the desired folder structure
in your case its apart from src\main\java
src\main\resources
src\main\webapp

Storing Visual Studio Solution with multiple projects in SVN

I am having a hard time adding a Visual Studio Solution with multiple projects to my repo. I am using VisualSVN. Here is my directory structure
c:\-----
|
---Projects
|
--MyApp
|
---Project1 (The solution is in this project directory)
---Project2
---Project3
When I select "MyApp" as the working copy root, nothing is added. If I select one of the project folder, only 2 are added.
Here's the structure I use with success:
dev
|- Project root folder (solution file here is the key)
|- Class Project
|- Class Project
|- Web Project
|- References
|- Resources
What I'm suggesting is that you should move your .sln file to the top level then import.
Another advance approach.
Each project has it is own trunk with following structure
trunk
|- .sln
|- src
|- ClassProject
|- Web Project
Then in a separate svn directory create sub directory for every solution you need. For example you can have AllProjects, WebOnly, DALOnly.
And using svn:externals bring every project you need (ClassProject etc.) in given case.

Resources