请问怎么解决servlet编译时显示不存在mybean.date?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了请问怎么解决servlet编译时显示不存在mybean.date?相关的知识,希望对你有一定的参考价值。

程序包javax.servlet不存在,并且程序包javax.servlet.http不存在等错误。我查阅了一下资料由于servlet和JSP不是java平台j2se(标准版)的一部分,而是j2EE的一部分,因此必须告知编译器servlet的位置。
解决方案如下:
1.注意大小写的问题。servlet的字母要注意是小写。

2.搜索servlet-api.jar,在tomcat文件夹中。

3.更改环境变量中CLASSPATH的值,将搜索到的servlet-api.jar的路径全部复制到属性值中去。(这里要注意,复制的过程中要把后缀名.jar也要复制过去)
参考技术A 编译的时候带包名,
比如 javac myservlet\control\HandleRegister.java

UITableviewCell在ios中滚动时显示不正确

【中文标题】UITableviewCell在ios中滚动时显示不正确【英文标题】:UITableviewCell displaying incorrectly during scrolling in ios 【发布时间】:2014-04-30 11:31:37 【问题描述】:

我有一个表格视图,我需要在其中显示一些问题文本及其答案类型。答案类型可以是 UISwitch (single_option)、UITextField (text_option) 和 Star Rating View (star_option)。所有问题及其答案类型均来自服务器。因此,对于每个表格行,我需要显示一个问题文本和一个答案类型,正如我在下面的屏幕截图中提到的那样。可以有 n 个问题,所以我根据问题的数量设置了它们的框架。现在,我的问题是当我向上或向下滚动时,问题显示正确,但他们的答案类型是随机出现的,而且我没有得到正确的单元格高度。

请检查,我正在附上我的代码。

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

        Surveys *surveys = [[Surveys alloc] init];
        surveys = [arraySurveys objectAtIndex:indexPath.row];
        static NSString *CellIdentifier = @"Cell";

        UITableViewCell *surveysCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (!surveysCell) 
            surveysCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

            UILabel *lblSurveyQuestionText = nil;
            SVSegmentedControl *segment1 = nil;
            UITextField *tfAnswer = nil;

            //For displaying Voting Questions
            lblSurveyQuestionText = [[UILabel alloc] init];
            labelHeight = [self getLabelHeightForIndex:indexPath.row];

            lblSurveyQuestionText.frame = CGRectMake(10, 5, 300,labelHeight);

            lblSurveyQuestionText.backgroundColor = [UIColor clearColor];
            lblSurveyQuestionText.text = surveys.questions;
            lblSurveyQuestionText.textAlignment = NSTextAlignmentLeft;
            lblSurveyQuestionText.lineBreakMode = NSLineBreakByWordWrapping;
            lblSurveyQuestionText.numberOfLines = 0;
            lblSurveyQuestionText.tag = 10;
            [lblSurveyQuestionText sizeToFit];
            lblSurveyQuestionText.textColor = [UIColor whiteColor];

            [surveysCell.contentView addSubview:lblSurveyQuestionText];

            //For displaying UISwitch
            NSArray *arrayOption1 = [[NSArray alloc] initWithObjects:@"Yes", @"No", nil];
            segment1 = [[SVSegmentedControl alloc] initWithSectionTitles:arrayOption1];

            segment1.thumb.tintColor = [UIColor colorWithRed:0.6 green:0.2 blue:0.2 alpha:1];

            segment1.changeHandler = ^(NSUInteger newIndex) 
                NSString *selectedName = [arrayOption1 objectAtIndex:newIndex];
                NSLog(@"Switch selected answer is = %@", selectedName);
            ;

            segment1.center = CGPointMake(65, lblSurveyQuestionText.frame.size.height+27);

            //For displaying text field
            tfAnswer = [[UITextField alloc] init];
            CGRect frameRect = CGRectMake(10, lblSurveyQuestionText.frame.size.height+13, 300, 25);
            frameRect.size.height = 25;
            tfAnswer.frame = frameRect;

            UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 7, 10)];
            tfAnswer.leftView = paddingView;
            tfAnswer.leftViewMode = UITextFieldViewModeAlways;
            tfAnswer.textColor = [UIColor colorWithRed:(59/255.0) green:(59/255.0) blue:(59/255.0) alpha:1.0];
            tfAnswer.delegate = self;
            tfAnswer.font = [UIFont fontWithName:@"Helvetica Neue Medium" size:16.0];
            tfAnswer.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"tf_301_23.png"]];\
            tfAnswer.returnKeyType = UIReturnKeyDone;

            //For displaying star view
            starRatingAnswer = [[TQStarRatingView alloc] initWithFrame:CGRectMake(10, lblSurveyQuestionText.frame.size.height+10, 180, 30) numberOfStar:5];
            starRatingAnswer.delegate = self;

            surveysCell.selectionStyle = UITableViewCellSelectionStyleNone;
            tblSurveys.tableFooterView = viewSurveysBottom;

            NSLog(@"Surveys answer type is = %@", surveys.answer_type);

            if ([surveys.answer_type isEqualToString:@"text_option"]) 

                [surveysCell.contentView addSubview:tfAnswer];
            
            else if ([surveys.answer_type isEqualToString:@"single_option"]) 

                [surveysCell.contentView addSubview:segment1];
            
            else

                [surveysCell.contentView addSubview:starRatingAnswer];
            
            return surveysCell;

        

        ((UILabel *)[surveysCell.contentView viewWithTag:10]).text = surveys.questions;
        return surveysCell;

JSON:


    "Question_sq_details": [
        
            "event_sq_qns_id": 3,
            "questions": "Effectiveness of the speakers",
            "answer_type": "star_option"
        ,
        
            "event_sq_qns_id": 4,
            "questions": "What is your primary job title/focus? Please select one.",
            "answer_type": "single_option"
        ,
        
            "event_sq_qns_id": 5,
            "questions": "Quality of the content",
            "answer_type": "star_option"
        ,
        
            "event_sq_qns_id": 6,
            "questions": "Usefulness of the Solutions Showcase",
            "answer_type": "text_option"
        ,
        
            "event_sq_qns_id": 7,
            "questions": "Relevance of the Solutions Showcase to your business",
            "answer_type": "star_option"
        ,
        
            "event_sq_qns_id": 8,
            "questions": "Relevance of the topics to your business",
            "answer_type": "star_option"
        ,
        
            "event_sq_qns_id": 9,
            "questions": "General Comments",
            "answer_type": "text_option"
        
    ]

请提出一些克服这种情况的方法。我已经尝试了很多,但使用我上面的代码似乎没有任何效果。

谢谢。

【问题讨论】:

用这个来为你带来希望***.com/questions/22862938/… 非常感谢@Anbu.Karthik..现在它的工作。但是你能告诉我如何保存他们所有的答案行。我需要将他们的答案发送回服务器? 你能说清楚吗,你需要什么答案 okey..假设我在表格单元格上显示三个问题,答案类型为 UITextfield。所以一旦用户给出他们的答案..我需要正确保存所有答案表行。 正确保存意味着您需要将数据发送到服务器或将问题与答案对齐 【参考方案1】:

您有三种类型的单元格,以不同的方式处理它们。 并且不要忘记使用预处理器宏而不是纯数字作为tags。

#define lblSurveyQuestionTextTag 10

顺便说一句,我更喜欢继承 UITableViewCell 而不是像这样搞砸。

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

    Surveys *surveys = [[Surveys alloc] init];
    surveys = [arraySurveys objectAtIndex:indexPath.row];

    // differenct identifiers based on different type of cells
    static NSString *CellIdentifier = surveys.answer_type;

     UITableViewCell *surveysCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
     if (!surveysCell) 
        // Setup shared property
         surveysCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
         surveysCell.selectionStyle = UITableViewCellSelectionStyleNone;
        tblSurveys.tableFooterView = viewSurveysBottom;

        UILabel *lblSurveyQuestionText = nil;

        //For displaying Voting Questions
        lblSurveyQuestionText = [[UILabel alloc] init];
        labelHeight = [self getLabelHeightForIndex:indexPath.row];

        lblSurveyQuestionText.frame = CGRectMake(10, 5, 300,labelHeight);

        lblSurveyQuestionText.backgroundColor = [UIColor clearColor];
        lblSurveyQuestionText.text = surveys.questions;
        lblSurveyQuestionText.textAlignment = NSTextAlignmentLeft;
        lblSurveyQuestionText.lineBreakMode = NSLineBreakByWordWrapping;
        lblSurveyQuestionText.numberOfLines = 0;
        lblSurveyQuestionText.tag = 10;
        [lblSurveyQuestionText sizeToFit];
        lblSurveyQuestionText.textColor = [UIColor whiteColor];

        [surveysCell.contentView addSubview:lblSurveyQuestionText];

        // end setup shared properties

        if ([surveys.answer_type isEqualToString:@"text_option"])  // setup text_option type
        //For displaying text field
            UITextField *tfAnswer = [[UITextField alloc] init];
            CGRect frameRect = CGRectMake(10, lblSurveyQuestionText.frame.size.height+13, 300, 25);
            frameRect.size.height = 25;
            tfAnswer.frame = frameRect;

            UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 7, 10)];
            tfAnswer.leftView = paddingView;
            tfAnswer.leftViewMode = UITextFieldViewModeAlways;
            tfAnswer.textColor = [UIColor colorWithRed:(59/255.0) green:(59/255.0) blue:(59/255.0) alpha:1.0];
            tfAnswer.delegate = self;
            tfAnswer.font = [UIFont fontWithName:@"Helvetica Neue Medium" size:16.0];
            tfAnswer.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"tf_301_23.png"]];\
            tfAnswer.returnKeyType = UIReturnKeyDone;
            tfAnswer.tag = 2555;
            [surveysCell.contentView addSubview:tfAnswer];
        
        else if ([surveys.answer_type isEqualToString:@"single_option"])  // setup single_option type
            //For displaying UISwitch
            NSArray *arrayOption1 = [[NSArray alloc] initWithObjects:@"Yes", @"No", nil];
            SVSegmentedControl *segment1 = [[SVSegmentedControl alloc] initWithSectionTitles:arrayOption1];

            segment1.thumb.tintColor = [UIColor colorWithRed:0.6 green:0.2 blue:0.2 alpha:1];

            segment1.center = CGPointMake(65, lblSurveyQuestionText.frame.size.height+27);

            segment1.changeHandler = ^(NSUInteger newIndex) 
            NSString *selectedName = [arrayOption1 objectAtIndex:newIndex];
            NSLog(@"Switch selected answer is = %@", selectedName);
        ;

        segment1.tag = 2556;
        [surveysCell.contentView addSubview:segment1];
    
    else // setup star type
        //For displaying star view
        /* TQStarRatingView * */starRatingAnswer = [[TQStarRatingView alloc] initWithFrame:CGRectMake(10, lblSurveyQuestionText.frame.size.height+10, 180, 30) numberOfStar:5];
        starRatingAnswer.delegate = self;
        starRatingAnswer.tag = 2557;
        [surveysCell.contentView addSubview:starRatingAnswer];
        
    

    if ([surveys.answer_type isEqualToString:@"text_option"]) 
        UITextField *tfAnswer = (UITextField*)[surveysCell.contentView viewWithTag:2555];
        // tfAnswer.text = @""
    
    else if ([surveys.answer_type isEqualToString:@"single_option"]) 
        SVSegmentedControl *segment1 = (SVSegmentedControl*)[surveysCell.contentView viewWithTag:2556];
        // segment1.selectedIndex = 1;
    
    else
        TQStarRatingView *starRatingAnswer = (TQStarRatingView*)[surveysCell.contentView viewWithTag:2557];
        // starRatingAnswer.stars = 5;
    

    // NSlog cause performance loss in TableView, turn it off when not needed or release/adhoc builds
    NSLog(@"Surveys answer type is = %@", surveys.answer_type);

    ((UILabel *)[surveysCell.contentView viewWithTag:10]).text = surveys.questions;
    return surveysCell;

【讨论】:

以上是关于请问怎么解决servlet编译时显示不存在mybean.date?的主要内容,如果未能解决你的问题,请参考以下文章

eclipse share project到svn时显示不被信任的证书,暂时接受也不行

自定义 tableViewCell 滚动时显示不正确

微信小程序原生组件cover-view内当文字超出宽度时显示不全

UITableviewCell在ios中滚动时显示不正确

Java FileInputStream.read() 打印时显示不需要的字符

Android ListView 在向下滚动时显示不正确的内容,然后在向上滚动时显示正确的内容