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 7857209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:57:57+00:00 2026-06-02T20:57:57+00:00

Is it possible to define the type of the view commands in Spring? As

  • 0

Is it possible to define the type of the view commands in Spring? As it is right now, it is dangerous for us to change anything in our command classes. Properties on these classes may be used by the view (path="myDto.persons[0].name"), but if anything in the command class changes, the view will only fail runtime.

All other parts of our MVC stack is tested, so we can safely do refactorings when needed. The only problem is with the view, as the paths are “just strings”, and we cannot in any reasonable way search and replace everywhere we use the specific command.

It would be a great help if there was some way to tell Spring what type the command actually is, so it could be validated when we do precompilation of our .jsp’s. An added bonus would also be completion when editing the view, but I guess that is more of an IDE issue.

So, do any of you know how and if this is possible?

  • 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-02T20:57:59+00:00Added an answer on June 2, 2026 at 8:57 pm

    It might be possible to add type safety to your views if you completely redesign your JSP files (in a very ugly way if I may say so myself).

    Servlets offer you type safety since that’s Java code. If you refactor your classes and miss something, the compiler will immediately tell you you missed it. But JSPs replace servlets as a view technology offering a much more dynamic/rapid development pace (no more endless out.write instructions opening tags, closing them, escaping quotes etc).

    EL expressions, as you noticed, are basically strings which later get evaluated and fail at runtime if something is off. Even if you precompile the JSPs, it would still fail because ELs remains as strings in the generated servlet. They are either passed as such to tags and they evaluate it themselves, or if using a JSP 2.x version, the servlet container itself wraps the expression in an evaluation call before passing it as a value.

    Basically for a version less than JSP 2, for a tag like:

    <my:tag value="${bean.someProp}" />
    

    You get a result like:

    myTagInstance.setValue("${bean.someProp}");
    

    in the servlet.

    The tag itself will do the evaluation of that string, at runtime.

    For JSP 2 you don’t get any better, the evaluation still occurs at runtime but the servlet container takes this burden away from the tag, generating a code like:

    myTagInstance.setValue((SomePropTypeCastHere) ProprietaryServletContainerEvaluationUtil.evaluate("${bean.someProp}"));
    

    If the content of the object itself isn’t the expected one when evaluation occurs, you get weird results or errors.

    The only way (I know) to enforce static typing in a JSP is to bring Java code back in the JSP (the thing EL was invented to eliminate). That is why I said at the begging that you have to change your JSP in an ugly way.

    If all your tags can use <rtexprvalue>true</rtexprvalue> values, you can use scriptlets to enforce type safety.

    A tag like:

    <my:tag value="<%=bean.getSomeProp()%>" />
    

    now gets converted to this:

    myTagInstance.setValue(bean.getSomeProp());
    

    If the someProp property was renamed, deleted, changed type or whatever, the compiler can tell you about it. The IDE itself should be able to tell you, you don’t even need to precompile the JSPs.

    If I’m not mistaken, the Spring tags support runtime expressions so this should work… if you are willing to mess up your JSPs that is!

    As for the IDE support for completion, you have that for scriptlets but not for EL. That’s because for EL it’s the same discussion, it happens at runtime. How is the IDE to know what’s in context (page, request, session etc) when the JSP is executed, and know that when you are developing the JSP?

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

Sidebar

Related Questions

Is it possible to define an array of text fields (or any data type)
In object type macro it is possible below, #define str this is a string
Is it possible to define a event handler of one type of HTML object
Is it possible in C# to define return type of a method as some
How is it possible to define a Spring beans which need only @Autowired for
Is it possible to define a standard ServiceHostFactory foreach 'workflow' service (xamlx) Our customers
Is it possible to define the return type like this? public static function bool
Is it possible to define a user-defined type constant at module level? Type MyType
Is it possible to define type converter for binding inline (without resource)? Something like
Is it possible to define a type which can be either a keyref or

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.