首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

jsp中的switch有关问题

2012-01-02 
jsp中的switch问题!部分代码:Stringxmlbrs.getString(xmlb)switch(xmlb){case BHJS :xmztmessage

jsp中的switch问题!
部分代码:
String xmlb=rs.getString("xmlb");
switch(xmlb){
  case "BHJS" :  
  xmztmessage="项目驳回结束"; 
  case "UTOG" :
  xmztmessage="用户向管理员申请,待管理员审核";
  case "YSCTOG" :  
  xmztmessage="厂家预算提交管理员审核";……………………
问题:Sting的switch不能用,如何把String转换成char。case比较多,有什么好的方法请大家多多指教!

[解决办法]
jdk1.7 switch支持 String类型。。
[解决办法]
HashMap<String,Integer> map = new HashMa<String,Integer>();
map.put("BHJS",1);
map.put("UTOG",2);
map.put("YSCTOG",3);
String xmlb=rs.getString("xmlb");
int i = map.get(xmlb);
switch(i){
case 1 :
xmztmessage="项目驳回结束"; 
case 2 :
xmztmessage="用户向管理员申请,待管理员审核";
case 3 :
xmztmessage="厂家预算提交管理员审核";……………………
[解决办法]
java7支持的。

热点排行