请教自定义网页后缀名问题?
篮球公园的网站 http://www.cctv.hoopark.cn/index.htm 里面的页面的后缀名都是.park的,请问各位这个是怎么实现的??自定义网页后缀名.我不知道其他有没有这样的站点.
------解决方案--------------------我就将西红柿叫苹果你怎么招吧!
------解决方案--------------------可以使用urlrewirte来处理,具体的自己了解去吧
------解决方案--------------------WEB服务器设置一下
------解决方案--------------------urlrewirte 正解 可以把jsp什么的映射为任何后缀
------解决方案--------------------没错
就是这个 urlrewirte
------解决方案--------------------写一个继承javax.servlet.Filter接口的类
public class HibernateFilter implements Filter {
private String encode = "UTF-8 ";
public void init(FilterConfig config) {
this.encode = config.getInitParameter( "encode ");
}
public void doFilter(
ServletRequest request,
ServletResponse response,
FilterChain chain)
throws
IOException,
ServletException {
HttpServletRequest httpServletRequest = ((HttpServletRequest) request);
String uri = httpServletRequest.getServletPath().trim();
if (uri.endsWith( ".park ")) {
httpServletRequest.getRequestDispatcher( "对应页面 ").forward(httpServletRequest,response);//转向真实的对应页面
}
else{
chain.doFilter(request, response);
}
}
}
web.xml中配置
<filter>
<filter-name> HibernateFilter </filter-name>
<filter-class> com.dsii.common.web.filter.HibernateFilter </filter-class>
<init-param>
<param-name> encode </param-name>
<param-value> UTF-8 </param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name> HibernateFilter </filter-name>
<url-pattern> /* </url-pattern>
</filter-mapping>
------解决方案--------------------后缀名有影响吗?
你把一个写好的html文件如:test.html改成test.park
再在浏览器中输入http://localhost/test.park
一样能访问的,只是不能通过双击打开罢了
------解决方案--------------------使用Servlet进行映射就行.
<servlet>
<servlet-name> action </servlet-name>
<servlet-class> org.apache.struts.action.ActionServlet </servlet-class>
<init-param>
<param-name> config </param-name>
<param-value> /WEB-INF/struts-config.xml </param-value>
</init-param>
<init-param>
<param-name> config/example </param-name>
<param-value> /WEB-INF/example/struts-config-example.xml </param-value>
</init-param>
<load-on-startup> 3 </load-on-startup>
</servlet>
<!-- Action Servlet Mapping -->
<servlet-mapping>
<servlet-name> action </servlet-name>
<url-pattern> *.py </url-pattern>
</servlet-mapping>
------解决方案--------------------我就知道一种,就楼上说的那种Servlet映射