当前位置: 代码迷 >> Java Web开发 >> String literal is not properly closed by a double-quote解决办法
  详细解决方案

String literal is not properly closed by a double-quote解决办法

热度:1074   发布时间:2016-04-17 00:52:24.0
String literal is not properly closed by a double-quote
<%@page language="java" contentType="text/html;charset=GB2312"%>
<html>
<body>
<% if(reqest.getParameter("number")!=NULL&&request.getParamter("number")!=" ")
{
  int nub=Integer.parseInt(request.getParameter("number"));
  int c=((Integer)session.getAttribute("count")).intValue();
  int a=((Integer)session.getAttribute("num")).intValue();
  if(nub>a)
  {
  c++;
  String s=String.valueof(c);
  session.setAttribute("count",s);
  response.sendRedirect("1.html");
  } 
  if(nub=a)
  {
   
  out.println("恭喜你猜对了,答案是"+a);
  out.ptintln("你共用了 "+c+"次);
  }
  else
  {
  c++;
  String s=String.valueof(c);
  session.setAttribute("count",s);
  response.sendRedirect("2.html");
  } 
}  
%>
</body>
</html>
运行时时候就出现这个错误
An error occurred at line: 4 in the jsp file: /check.jsp
Generated servlet error:
String literal is not properly closed by a double-quote


org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 4 in the jsp file: /check.jsp
Generated servlet error:
String literal is not properly closed by a double-quote


org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
哪位帮我看看啊


------解决方案--------------------
我帮你修改了代码了 错误不少啊
你复制我给你修改后的代码吧

HTML code
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%><html><body><% int nub=0;int a=0;int c=0;if(request.getParameter("number")!=null&&request.getParameter("number")!=" "){  nub=Integer.parseInt(request.getParameter("number"));  c=((Integer)session.getAttribute("count")).intValue();  a=((Integer)session.getAttribute("num")).intValue();  if(nub>a)  {  c++;  String s=String.valueOf(c);  session.setAttribute("count",s);  response.sendRedirect("1.html");  }    if(nub==a)  {      out.println("恭喜你猜对了,答案是"+a);  out.println("你共用了 "+c+"次");  }  else  {  c++;  String s=String.valueOf(c);  session.setAttribute("count",s);  response.sendRedirect("2.html");  }  }   %></body></html>
  相关解决方案