本文介绍了如何将枚举和路由传递给采用int的操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我需要在动作中传递负数,但在地址栏中我不想显示负数。 这个负数是枚举值。 mydomain.com/myprojects/Days/Index/0 mydomain.com/myprojects/Days/Index/-3 我尝试了什么: 目前我传递了enum的负int值解决方案 我认为你有设计问题,应该摆脱负面的枚举。必要时重构。 否定枚举没有任何好处。我所期望的唯一标准是未知或默认的默认值0。 事实上你甚至需要考虑如何处理它表明它是一个设计错误(来自标准)。 I need to pass negative number in the action but in the address bar i do not want negative number to display.This negative number is value for an enum.mydomain.com/myprojects/Days/Index/0mydomain.com/myprojects/Days/Index/-3What I have tried:Currently I am passing negative int value of enum 解决方案 I think you have design issues, and should get rid of the "negative" enums. Refactor if necessary.There is no advantage to negative enums. The only "standard" I would expect would be a default of "0" for "Unknown" or "Default".The fact you have to even think about how to handle it shows it's a design error (from the norm). 这篇关于如何将枚举和路由传递给采用int的操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-24 01:47