servlet的web.xml文件的模板

<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"

 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee

    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

 <servlet>

  <servlet-name>helloServlet</servlet-name>

  <!-- servlet-class:一定要将类的完整的名称写出来 -->

  <servlet-class>web.HelloServlet</servlet-class>

 </servlet>

 <servlet-mapping>

  <servlet-name>helloServlet</servlet-name>

  <url-pattern>/sayHello</url-pattern>

 </servlet-mapping>

</web-app>

 

 

web.xml中错误处理页面的配置

     <error-page>

        <!--方式1 -->

        <error-code>500</error-code>

        <!--方式2

        <exception-type>javax.servlet.ServletException

        </exception-type>

         -->

        <location>/error.html</location>

    </error-page>


 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的 springmvc.xml 文件模板,你可以根据自己的需求进行修改: ```xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> <!-- 开启 Spring 的注解功能 --> <context:annotation-config/> <context:component-scan base-package="com.example"/> <!-- 开启 Spring MVC 注解驱动 --> <mvc:annotation-driven/> <!-- 配置视图解析器 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/"/> <property name="suffix" value=".jsp"/> </bean> <!-- 配置静态资源路径 --> <mvc:resources mapping="/resources/**" location="/resources/"/> <!-- 配置拦截器 --> <mvc:interceptors> <bean class="com.example.MyInterceptor"/> </mvc:interceptors> <!-- 配置文件上传 --> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="maxUploadSize" value="10000000"/> </bean> </beans> ``` 其中,`<context:component-scan>` 标签用于扫描指定包下的组件,`<mvc:annotation-driven>` 标签用于开启 Spring MVC 的注解驱动,`<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">` 标签用于配置视图解析器,`<mvc:resources>` 标签用于配置静态资源路径,`<mvc:interceptors>` 标签用于配置拦截器,`<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">` 标签用于配置文件上传。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值