java - spring mvc 返回值加密
PHPz
PHPz 2017-04-18 10:31:39
0
6
519

项目中使用spring mvc的@ResponseBody注解返回结果,现在的需求是不改变原来的业务逻辑代码,对结果进行加密,如何处理?

@Controller @RequestMapping(value = "/crypt") public class CryptController { @ResponseBody @RequestMapping(value = "/decrypt", method = RequestMethod.GET) public String decrypt(int id, String name) { return "id=" + id + ", name=" + name; } }

本人尝试使用Filter处理,但是没成功,求高手指教。

PHPz
PHPz

学习是最好的投资!

reply all (6)
PHPzhong

Do you want to encrypt your password? ? Can be encrypted with md5

    小葫芦
    • Don’t change the original code? Does it mean that the code is not changed? Business logic or code for the entire project?

    • You can try to write an encryption tool class, throw the things you want to encrypt into it before returning and then return it again

      左手右手慢动作

      Can the filter print records?

        迷茫

        Isn’t the purpose of the question title to ensure safety? You can use the following methods
        1. Add token or session authentication to the request to prevent random calls
        2. You can use the postHandle method of Spring MVC Interceptor to further process the results

          阿神

          Just use the interceptor function that comes with spring mvc to implement it

            迷茫

            Isn’t it necessary to encrypt ""id=" + id + ", name=" + name"? What are they talking about upstairs... Each interface returns data encryption, decryption in the filter, using des, etc.

              Latest Downloads
              More>
              Web Effects
              Website Source Code
              Website Materials
              Front End Template
              About us Disclaimer Sitemap
              php.cn:Public welfare online PHP training,Help PHP learners grow quickly!