2 zv345653485 zv345653485 于 2013.11.27 10:45 提问

java web.xml 配置问题 velocity

1、没做任何修改的话需要localhost:8080/index这样指定才能进入index.vm,localhost:8080这样直接进入是进入404错误页面,我现在就把主页设置到了404错误里面,一直这样不是个办法
2、发现web.xml 中 welcome-file-list 这个无效,但是我把filter-mapping这个删了或者改成/index.vm就可以进入index.vm 但是后面的请求无法拦截 这里应该怎么修改?
如请求localhost:8080/index
java 里面 @ControlMapping(path = "/index")
web.xml如下
<?xml version="1.0" encoding="UTF-8"?>
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
mll2

<!-- mvc -->
<filter>
    <filter-name>plainFilter</filter-name>
    <filter-class>org.msf.mvc.web.RestFilter</filter-class>
    <init-param>
        <param-name>filters_packages</param-name>
        <param-value>com.bskj.mll.filter</param-value>
    </init-param>
    <init-param>
        <param-name>control_packages</param-name>
        <param-value>com.bskj.mll.control</param-value>
    </init-param>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
        <param-name>excludes</param-name>
        <param-value>.+\.jsp,/css/.+,/js/.+,/swf/.+,.+\.vm,/images/.+</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>plainFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Kaptcha -->
<servlet>
    <servlet-name>Kaptcha</servlet-name>
    <servlet-class>com.bskj.mll.common.KaptchaServlet</servlet-class>
    <init-param>
        <param-name>kaptcha.obscurificator.impl</param-name>
        <param-value>com.google.code.kaptcha.impl.ShadowGimpy</param-value>
    </init-param>
    <init-param>
        <param-name>kaptcha.border</param-name>
        <param-value>no</param-value>
    </init-param>
    <init-param>
        <param-name>kaptcha.textproducer.char.space</param-name>
        <param-value>5</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>Kaptcha</servlet-name>
    <url-pattern>/images/kaptcha.jpg</url-pattern>
</servlet-mapping>
<!-- velocity -->
<servlet>
    <servlet-name>velocity</servlet-name>
    <servlet-class>org.msf.mvc.plugin.velocity.servlet.VelocityServlet</servlet-class>
    <init-param>
        <param-name>org.apache.velocity.tools.deprecationSupportMode</param-name>
        <param-value>false</param-value>
    </init-param>
    <init-param>
        <param-name>org.apache.velocity.tools.cleanConfiguration</param-name>
        <param-value>true</param-value>
    </init-param>
    <init-param>
        <param-name>org.apache.velocity.tools.userCanOverwriteTools</param-name>
        <param-value>false</param-value>
    </init-param>
    <load-on-startup>10</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>velocity</servlet-name>
    <url-pattern>*.vm</url-pattern>
</servlet-mapping>

<welcome-file-list>
    <welcome-file>index.vm</welcome-file>
</welcome-file-list>
<error-page>
    <error-code>404</error-code>
    <location>/_mll_404.vm</location>
</error-page>
<error-page>
    <error-code>405</error-code>
    <location>/_mll_405.vm</location>
</error-page>
<error-page>
    <error-code>500</error-code>
    <location>/_mll_500.vm</location>
</error-page>

1个回答

demonxiao
demonxiao   2013.12.03 17:22

试试在根目录上建一个空的index.vm的文件。

zv345653485
zv345653485 基本每个目录我都建了个 试了没用
接近 4 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片