简体   繁体   中英

Web App Architecture

I'm currently working with two entities:

  • A JSP that uses jQuery
  • A RESTful WebService that I use to query a database for a collection of Foo objects.

In the JSP, I make an AJAX call the WS that returns my collection, and I begin to iterate through it, with the intent of displaying some of each Foo's variables in a data table. There's a business requirement that says, if Foo.bar is present, show it on the screen. Otherwise, in the bar column, show the value of Foo.baz. This, by my definition, is application-specific business logic.

My question: where should this logic go? I don't think it belongs in the WS, because I want myself and others to rely on this as your one-stop shop for getting raw Foo objects, not Foo objects that have had the above conditions applied to them. I also don't think it belongs in the JSP, because it should only be a means by which to display data. What am I missing?

You said it yourself:

There's a business requirement that says, if Foo.bar is present, .Otherwise, in the bar column, .

That sounds an awful lot like display logic, so I think the JSP is an appropriate place since it handles that layer of the application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM