Styling Custom Module

I am currently creating an OpenMRS module with jsp views. An issue I am currently facing is styling.

I want to apply minimal style to my views, but when I place the css file under the resources directory and call it from my jsp page, it does not seem to respond.

Below is my project structure:

So, I call from my jsp page: <link rel="stylesheet" type="text/css" href="resources/style.css"/> Even when I view my source file from browser, the location of the css seems not to even be recognized. Can anyone help please?

It’s important to know that the OpenMRS module framework copies module resources into the main WEB-INF directory, and they are also exposed via a specific ModuleResourceServlet:

I think the url you want to use is “/moduleResources/{{moduleId}}/style.css”.

Also, we have a helper taglib for including js and css (and this has the benefit of taking care of caching, i.e. it will append a query parameter that changes every time you restart OpenMRS or reload a module). Example:

<openmrs:htmlIncludefile="/moduleResources/htmlformentry/htmlFormEntry.css" />

2 Likes