Results 1 to 2 of 2

Thread: How to access context param in Controller

  1. #1
    Join Date
    Feb 2011
    Posts
    1

    Default How to access context param in Controller

    Hi!

    I am creating an online examination application, and I need to create a cheat mode wherein when enabled will allow me to view answers to questions. I am thinking of creating a context-param that will reflect this mode. My problem is how to access this paramter in my Controller.

    Here's what I have in my web.xml:

    ...
    <context-param>
    <param-name>godMode</param-name>
    <param-value>true</param-value>
    </context-param>
    ...


    Here's my controller:

    @RequestMapping("/getQuestions.do")
    public String retrieveExamQuestions(
    @RequestParam("passwordTxt") String password, @RequestParam("userProfileId") Long userProfileId,
    @RequestParam("employeeExamId") Long employeeExamId,
    ModelMap model){
    ...
    }


    Thanks in advance!

  2. #2
    Join Date
    Nov 2005
    Posts
    113

    Default

    Actually, I'd suggest making this a bit simpler. If you use a PropertyPlaceholderConfigurer to set a "godMode" variable in a properties file, you can just inject it into your controller using ${godMode}. This can even be controlled through a system property if you so desire.

    Hope this helps
    - Don

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •