关于web.xml

wangmin8908 2015-12-10 05:37:14
eclipse + tomcat 下配置web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">

<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
<welcome-file-list>
<welcome-file>main.htm</welcome-file>
</welcome-file-list>
<security-constraint>
<web-resource-collection>
<web-resouce-name>RegisteredUsers </web-resouce-name>
<url-pattern>/Tomcattest/security.jsp
</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>mldnuser</role-name>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Registered Users</realm-name>
</login-config>
<security-role>
<role-name>mldnuser</role-name>
</security-role>
<security-role>
<role-name>admin</role-name>
</security-role>
</web-app>
在web.xml
里面写这个
<web-resouce-name>RegisteredUsers </web-resouce-name>
这行为什么会有错啊
cvc-complex-type.2.4.a: Invalid content was found starting with element 'web-resouce-name'. One of '{"http://java.sun.com/xml/ns/javaee":web-resource-name}' is expected.
...全文
129 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
_南天北落 2015-12-11
  • 打赏
  • 举报
回复
<security-constraint> 的子元素 <http-method> 是可选的,如果没有 <http-method> 元素,这表示将禁止所有 HTTP 方法访问相应的资源。 子元素 <auth-constraint> 需要和 <login-config> 相配合使用,但可以被单独使用。如果没有 <auth-constraint> 子元素,这表明任何身份的用户都可以访问相应的资源。也就是说,如果 <security-constraint> 中没有 <auth-constraint> 子元素的话,配置实际上是不起中用的。如果加入了 <auth-constraint> 子元素,但是其内容为空,这表示所有身份的用户都被禁止访问相应的资源。
02.<security-constraint>   
03.  <display-name>   
04.  baseporject</display-name>   
05.  <web-resource-collection>   
06.   <web-resource-name>baseproject</web-resource-name>   
07.   <url-pattern>*.jsp</url-pattern>   
08.   <url-pattern>*.do</url-pattern>   
09.   <http-method>GET</http-method>   
10.   <http-method>PUT</http-method>   
11.   <http-method>HEAD</http-method>   
12.   <http-method>TRACE</http-method>   
13.   <http-method>POST</http-method>   
14.   <http-method>DELETE</http-method>   
15.   <http-method>OPTIONS</http-method>   
16.  </web-resource-collection>   
17.  <auth-constraint>   
18.   <description>   
19.   baseproject</description>   
20.   <role-name>All Role</role-name>   
21.  </auth-constraint>   
22.  <user-data-constraint>   
23.   <transport-guarantee>NONE</transport-guarantee>   
24.  </user-data-constraint>   
25.</security-constraint>  
_南天北落 2015-12-11
  • 打赏
  • 举报
回复
wangmin8908 2015-12-11
  • 打赏
  • 举报
回复
没人吗?

81,095

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧