<%@ Application Codebehind="Global.asax.cs" Inherits="blog.MvcApplication" La
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了<%@ Application Codebehind="Global.asax.cs" Inherits="blog.MvcApplication" La相关的知识,希望对你有一定的参考价值。
“/”应用程序中的服务器错误。分析器错误
说明: 在分析向此请求提供服务所需资源时出错。请检查下列特定分析错误详细信息并适当地修改源文件。
分析器错误消息: 未能加载类型“blog.MvcApplication”。
源错误:
<%@ Application Codebehind="Global.asax.cs" Inherits="blog.MvcApplication" Language="C#" %>
怎样编译?能详细点吗?
追答对项目,右键编译
追问就是编译重新生成项目,这个应该是编译,编译没错,调试的时候出现这个错误!
追答那 blog.MvcApplication 类存在吗,是不是误删或改名了?
追问没说要建这个类,后来我去建了还是不行?提示错误不变
JSP内置对象 - application对象和各对象的作用域
1、application对象的常用方法:
<table> <tr> <%-- 获取当前Web服务器的版本信息--%> <td>getServerInfo</td> <td><%=application.getServerInfo()%></td> </tr> <tr> <%-- 获取某一资源的路径--%> <td>getResource</td> <td><%=application.getResource("/application_test.jsp")%></td> </tr> <tr> <%-- 获取根目录的路径--%> <td>getRealPath</td> <td><%=application.getRealPath("/")%></td> </tr> <tr> <%-- 获取当前Web应用程序的名称--%> <td>getServletContextName</td> <td><%=application.getServletContextName()%></td> </tr> </table>
2、application、request、pageContext、session对象的作用域
<%-- Created by IntelliJ IDEA. User: Administrator Date: 2019/9/26 Time: 19:48 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>各对象的作用域</title> </head> <body> <% if (application.getAttribute("accessCount") == null) application.setAttribute("accessCount", new Integer(1)); else Integer accessCount = (Integer)application.getAttribute("accessCount"); accessCount += 1; application.setAttribute("accessCount", accessCount); %> <% if (request.getAttribute("accessCount") == null) request.setAttribute("accessCount", new Integer(1)); else Integer accessCount = (Integer)request.getAttribute("accessCount"); accessCount += 1; request.setAttribute("accessCount", accessCount); %> <% if (pageContext.getAttribute("accessCount") == null) pageContext.setAttribute("accessCount", new Integer(1)); else Integer accessCount = (Integer)pageContext.getAttribute("accessCount"); accessCount += 1; pageContext.setAttribute("accessCount", accessCount); %> <% if (session.getAttribute("accessCount") == null) session.setAttribute("accessCount", new Integer(1)); else Integer accessCount = (Integer)session.getAttribute("accessCount"); accessCount += 1; session.setAttribute("accessCount", accessCount); %> <%--application对象的作用域:开始于服务器的启动,终止于服务器的关闭--%> application: <%=application.getAttribute("accessCount")%><br /> <%--request对象的作用域:该页面和从该页面转向的页面--%> request: <%=request.getAttribute("accessCount")%><br /> <%--pageContext对象的作用域:该页面--%> pageContext: <%=pageContext.getAttribute("accessCount")%><br /> <%--session对象的作用域:浏览器第一次向服务器发送请求到存储时间结束或显式调用invalidate方法--%> session: <%=session.getAttribute("accessCount")%><br /> <%--<%request.getRequestDispatcher("index.jsp").forward(request,response);%>--%> </body> </html>
index.jsp :
<%-- Created by IntelliJ IDEA. User: Administrator Date: 2019/9/26 Time: 19:31 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>index.jsp页面</title> </head> <body> <% if (request.getAttribute("accessCount") == null) request.setAttribute("accessCount", new Integer(1)); else Integer accessCount = (Integer)request.getAttribute("accessCount"); accessCount += 1; request.setAttribute("accessCount", accessCount); %> <%=request.getAttribute("accessCount")%> </body> </html>
参考文档:
1)https://www.cnblogs.com/mark5/p/11075493.html
2)https://wenku.baidu.com/view/d98cea41336c1eb91b375d07.html
3)https://www.e-learn.cn/content/qita/2362810
4)https://www.cnblogs.com/chao521/p/9189484.html
以上是关于<%@ Application Codebehind="Global.asax.cs" Inherits="blog.MvcApplication" La的主要内容,如果未能解决你的问题,请参考以下文章
JSP内置对象 - application对象和各对象的作用域
cshtml 中的 AppState = Context.Application 和 控制器中的 Application 也相等
<receiver> 元素必须是 <application> 元素的直接子元素