【问题标题】:In jsp: String cannot be resolved to a type在jsp中:字符串无法解析为类型
【发布时间】:2014-11-11 12:46:29
【问题描述】:
<%
String bn=request.getParameter("branch");
if(bn.equals("MK")){
%>

我在 myeclipse 中遇到错误

字符串无法解析为类型

ServletRequest 类型中的方法 getParameter(String) 引用了缺少的类型 String

在这一行找到多个注释: - 字符串无法解析为类型 - 来自 ServletRequest 类型的方法 getParameter(String) 指的是缺失的 输入字符串

这是 Java 代码/bean 类,我在其中遇到“字符串”的相同错误 代码在这里

public class Customer {//for Customer i am getting this error- Implicit super constructor Object() is undefined for default constructor. Must define an explicit constructor
private int cid; // No error here

private String cname; //error here- String cannot be resolved to a type
private String email; //error here- String cannot be resolved to a type

private long phone;// No error here

// when i gives no arg constructor it gives this error
// Implicit super constructor Object() is undefined. Must explicitly invoke another constructor

//public Customer(){    }


}
...
...

} }

在它工作之前我在 Eclipse 中,现在它在 Myeclipse 中并且出现错误。 请告诉,我怎么能解决它。谢谢大家

另一个问题是 - 在 myeclipse 中,当我按下 Ctrl+空格(不起作用)时,它没有显示任何选项。

【问题讨论】:

  • 不要使用 Scriptlet 而是使用不易出错的 JSTLEL
  • 试试java.lang.String?

标签: jsp jsp-tags myeclipse


【解决方案1】:

可能是 JRE 系统库未绑定错误。 请右键单击您的项目选择“Properties->Java Build Path->Libraries”,单击JRE system library->edit->workspace default JRE。 会好的

【讨论】:

    【解决方案2】:

    尝试切换到新的工作区并导入您的项目,看看问题是否仍然存在。如果是这样,我建议重新安装 MyEclipse,因为它看起来好像 java 验证被搞砸了。或者,也许使用 -clean 选项启动 MyEclipse 可能会有所帮助(在 myeclipse.ini 文件的顶部添加“-clean”)。如果可以解决问题,请删除该选项,因为它会减慢启动速度。

    如果做不到这一切,需要更多细节,所以我建议在 myeclipse 论坛上提出。

    【讨论】:

      【解决方案3】:

      确保 Java 编译器级别与配置标签下的 pom.xml 中的相同。例如,如果你的 Java 编译器是 1.7,那么配置标签中的源和目标应该是 1.7。进行更改后,右键单击项目-->Maven-->更新项目。

      <configuration>
             <source>1.7</source>
             <target>1.7</target>
      </configuration>
      

      【讨论】:

      • java.lang.String 回到 Java 1.0。这不可能是解释。
      【解决方案4】:

      我可以通过单击 jsp 上的右键并选择“验证”来解决此问题。

      【讨论】:

        猜你喜欢
        • 2013-07-17
        • 1970-01-01
        • 2021-04-24
        • 2012-05-27
        • 2011-11-30
        • 2012-09-12
        • 1970-01-01
        • 2012-07-17
        • 2011-10-08
        相关资源
        最近更新 更多