What is the best practice for validating parameters in JSP?

前端 未结 2 985
攒了一身酷
攒了一身酷 2020-12-11 10:13

I\'m implementing a JSP which expects a few parameters which have to be validated before running the jsp.

  1. Suggestion: Validate the parameters inside the JSP us
2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-11 11:00

    Use an MVC Framework (Spring MVC, Stripes, Struts 2 etc.) and validate the parameters in the controller class. Every MVC framework supports parameter validation, and you get a clean separation of concerns.

    Example: Spring MVC automatically registers JSR-303-style parameter Validation (if you have a JSR-303 provider, e.g. Hibernate-Validator, on the classpath) when using mvc:annotation-driven

提交回复
热议问题