How to access jsp files folders of subfolders Spring MVC - spring

Hi StackOverflow Community i need help
How to access jsp files from, folders of subfolders Spring MVC
My project structrue is
WebContent
--WEB-INF
--Admin--index.jsp
--Student--Student.jsp
--Student
--StudentRecord--StudentRecord.jsp
--Fees
--StudentFees--StudentFees.jsp
i want to put all prefix " value path in Dispatcher-servlet.xml" ...how to do please help.
exclude this answer(in controller return "WEB-INF/Admin/index" )

Related

Can we provide JSP pages from sec/main/resources source folder

I am trying to provide JSP pages under sec/main/resources instead of webapp folder and configured source folder in application.properties as below but not working, let me know can we do this and how
spring.mvc.view.prefix=/src/main/resources
spring.mvc.view.suffix=.jsp

Config sub-folder in Thymelaf Spring Boot

How can I configure thymeleaf to recognize view/htmls under sub-folder?
I have templates/ folder right now and all my view HTML pages are found in this single folder.
By default spring-boot searches for all files and folders under resources. So feel free to create subfolder for example under templates/.
You just have to set the folder structure to your returning view or of your fragments in html.
Just an example of a project from me:
Controller:
#GetMapping(value = "/getAnyWellBox")
public String getAnyWellBox(Model model)
//any code
return "thirdparty/booking/map/well-box";
}

what is the url that I can use to access to a folder images in Spring Boot

Hey I have a problem with Spring boot what is the url that I can use in my controller for save images In a folder exist in : " resources/static/images "
You can access the static resources by just appending the path of them inside the static/public folder to your base URL.
Example:
You have an image in the folder src/main/resources/static/images/brand.png, the URL for that would be ${host}/images/brand.png.

How to import css/js in spring MVC application jsp page

I am new to spring mvc , I am creating a user registration page , there I need to put external css and import external js .
I put the script tag with src and link tag with href. But i think in Spring MVC application they will not work straight forward.
For this I added resourceservlet mapping but still it is not working
I am not able to find any way how I csn include these assets in my jsp file.
Please help me to get this one.
Regards,
Pranav
Put the CSS, JS, image files, etc., into a directory (which may contain subdirectories) in your web site, and than map the requests to that directory:
<mvc:resources mapping="/resources/**" location="/public-resources/"/>
In this example the files are in the public-resources directory, and you refer to them using /resources in the link in your JSP.
For more information see Spring docs

Spring Security + Spring MVC how to integrate them properlly?

I have a working project with both frameworks doing fine
My problem is how to architect it.
I have set 3 Roles ( Admin, Operator, User), and one folder for each of them. like thid
WebContent
|___admin
|___user
|___operator
|___WEB-INF
|__jsp
in admin,user, and operator are those roles only jsps
in jsp are all public jsps.
Is this the right way to do it ?
because when I create my viewResolver it only points to Web-Inf->jsp... So I am having trouble to make my requests land on those folders.
I want to be able to put a .jsp in a folder so it would automatically be assigned to a Role.
But I would like to be able to reuse the JSPs too.
Should I create another view resolver to each of those folders ?
Should they all be inside the WEB-INF folder ?
What is the best (more used and simple) way of doing this ?
I just added the user role folders into WEB-INF and used redirect... now it's working.

Resources