spring mvc - One jsp for both add and update functionality -


this might basic question , still want know better approach in terms of performance , maintainability.

  1. i have page need add , update functionality, , have handled in same jsp for

eg:- managecouriers.jsp

, here have write more code check whether update or add action , in controller (i using spring mvc).

  1. if use separate jsp

eg:- addcourier.jsp , updatecourier.jsp

, here me straight forward, dont want check condition, here need less coding, , see both page have same attribute cases, hit in maintaining both pages if there future changes.

i feel both scenarios seems better ways, in state of confusion 1 choose, better performance , maintainability. valuable inputs

start least common denominator supports current , future forseable use-cases, , refactor when/if new requirements force to.

that said, you've described, easiest @ least maintenence point of view have single form, 2 buttons name attribute can distinguish server methods based on param attribute of @requestmapping, like

<input type="submit" class="button" name="add" value="add"/> <input type="submit" class="button" name="update" value="update"/> 

and distinguish conroller methods based on param e.g. edit

@requestmapping(method = requestmethod.post, params = "add") public string add() { ...   } 

and update

@requestmapping(method = requestmethod.post, params = "update") public string update() { ...   } 

Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -