DWR中web.xml配置

<script>function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}</script>

要加入到你的web.xml最少的代码就是简单地去申明DWR servlet,没有它DWR就不起作用。

<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>
org.directwebremoting.servlet.DwrServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>logLevel</param-name>
<param-value>warn</param-value>
</init-param>
<init-param>
<param-name>crossDomainSessionSecurity</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>

</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
在DWR2.x里,DwrServlets是类org.directwebremoting.servlet.DwrServlet ,尽管uk.ltd.getahead.dwr.DWRServlet仍然可以用。在DWR 1.x你不得不使用后者。 有些额外的servlet参数,在有些地方很重要。尤其debug参数 这个扩展DWR的标准结构是使用<init-params>。放在<servlet>内,就像如下使用 <servlet> <servlet-name>dwr-invoker</servlet-name> <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class> <init-param> <param-name>debug</param-name> <param-value>true</param-value> </init-param> </servlet>
另外,启动服务时,如果报如下错。 java.lang.IllegalArgumentException: DefaultContainer can't find a classes 是DWR2.0 加入了JDK5的注释(annotations).DwrServlet初始化的时候会去检查注释的类,找不到就抱错了。如果你不用annotations也可以忽略掉这个错误。不过看起来总是不爽。解决方案如下 <servlet> <servlet-name>dwr-invoker</servlet-name> <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class> <init-param>

<param-name>debug</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>classes</param-name> <param-value>java.lang.Object</param-value> </init-param> </servlet>

你可能感兴趣的:(Web,xml,servlet,DWR)