Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7749349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:01:33+00:00 2026-06-01T11:01:33+00:00

New to Spring-MVC. I want to store two properties (uploadFolder=.., downloadFolder=..) in a .properties

  • 0

New to Spring-MVC.

I want to store two properties (uploadFolder=.., downloadFolder=..) in a .properties file and
access it in HomeController class (automatically created by the MVC template).

Can you please guide me how..

1) Created an app.properties file with the above and placed it under /src/main/resources. is this correct or should it go under /webapp/resources?

2) Placed a bean in servlet-context.xml in the following manner. is this correct?

<beans:bean id="messageSource"
   class="org.springframework.context.support.ResourceBundleMessageSource">
   <beans:property name="basename" value="app" />
</beans:bean>

3) Now how do I access this in Java controllers?

4) How do I access these in a JSP?

I can’t tell how much I will thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:01:35+00:00Added an answer on June 1, 2026 at 11:01 am

    There are a few different ways to do it. I do the following. In app context:

    <util:properties id="myProps" location="classpath:app.properties" />
    

    Make sure you have the following at the top of your file to include the “util” namespace:

    xmlns:util="http://www.springframework.org/schema/util" 
    xsi:schemaLocation= "... http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"
    

    I usually put my properties files in src/main/resources. As long as they’re on the classpath, you’re good. Then, in your controller, you can annotate your field/method with:

    @Controller
    public class MyController {
    
        @Value("#{myProps['uploadFolder']}")
        private String uploadFolder
    
        @Value("#{myProps['downloadFolder']}")
        private String downloadFolder
    
        @RequestMapping("myPage")
        public String loadPage(ModelMap m) {
            m.addAttribute("uploadFolder", uploadFolder);
            m.addAttribute("downloadFolder", downloadFolder);
            return "myPage";
        }
    
        public void setUploadFolder(String uploadFolder) {
            this.uploadFolder = uploadFolder;
        }
        public void setDownloadFolder(String downloadFolder) {
            this.downloadFolder = downloadFolder;
        }
    }
    

    Then, in your JSP:

    Download folder: ${downloadFolder} <br/>
    Upload folder: ${uploadFolder}
    

    HTH. Let me know if you have any questions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm fairly new to Spring and I need a bean that has two properties
I have a strange problem. When I want to create a new Spring MVC
I am new to Spring MVC and JUnit. Basically I want to autowire the
I want to do a mcq with Spring mvc. I've got a class Mcq
I want to create a new application in Spring MVC, before start it, I
Hello guys I am new to Spring MVC and i want to create a
I'm used to Java EE but not Spring MVC. I've just created a new
I am new to Spring MVC . I have a web application. I have
I am new to spring MVC. i have below project structure. Below are classes:
I'm new to Spring MVC, so I'm confused. I've used MVC in Struts, so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.