英文:
Spring Expression language - map values based on url (based on the path without host and port)
问题
我正在尝试在SpEL(Spring表达式语言)中映射一个值。
我需要根据URL路径映射某些值
https://www1.qa4.testsite.com/sso-login :External
https://www1.qa4.testsite.com/www :Normal
https://www.testsite.com/main/personal :Marketing
除了检查整个字符串值之外,还需要表达式来仅检查路径('sso-login','www','main/personal')
`#map(#requestInfo.httpReferer,
{ 'https://www1.qa4.testsite.com/sso-login': 'External', 'https://www.testsite.com/main/personal': 'Marketing', 'https://www1.qa4.testsite.com/www': 'Normal' }, 'Normal')`
英文:
I am trying to map a value in SpEL (Spring Expression Language).
I need to map certain values based on the url path
https://www1.qa4.testsite.com/sso-login : External
https://www1.qa4.testsite.com/www : Normal
https://www.testsite.com/main/personal : Marketing
What would be the expression to achieve this value other than checking the whole string value. Need expression to check only the path ('sso-logn' , 'www' , 'main/personal')
#map(#requestInfo.httpReferer,
{'https://www1.qa4.testsite.com/sso-login': 'External', 'https://www.testsite.com/main/personal': 'Marketing', 'https://www1.qa4.testsite.com/www': 'Normal'}, 'Normal')
答案1
得分: 0
有一个有效的表达式
#map(#requestInfo?.httpReferer?.split("m/")?.$[true], {'sso-login': 'External', 'www': 'Marketing', 'main/personal': 'Normal'}, 'Normal')
<details>
<summary>英文:</summary>
Got a working expression
#map(#requestInfo?.httpReferer?.split("m/")?.$[true], {'sso-login': 'External', 'www': 'Marketing', 'main/personal': 'Normal'}, 'Normal')
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论