web.xml部分代码如下:
<servlet>
<servlet-name>HelloFreeMarker</servlet-name>
<servlet-class>Freemarker.HelloFreeMarker</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloFreeMarker</servlet-name>
<url-pattern>/hello.servlet</url-pattern>
</servlet-mapping>
<filter>
<filter-name>struts</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
servlet的<url-pattern>加上后缀名,struts配置不变,在url地址栏需要访问servlet的时候加上后缀名即可
如下:http://localhost:8080/项目名称/hello.servlet