Undefined attribute name (role), eclipse

I have the following file structure

WebContent-> Bootstrap →

Js

CSS

IMG

WebContent-> index.jsp

None of the following two URLs help resolve the undefined attribute error.

Undefined attribute name (data switching)

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <button type="submit" class="btn btn-default">Submit</button> <span class="label label-primary">Primary</span> <span class="label label-success">Success</span> <span class="label label-info">Info</span> <span class="label label-warning">Warning</span> <span class="label label-danger">Danger</span> <a href="#">Inbox <span class="badge">42</span></a> </div> <div class="jumbotron"> <h1>Hello, world!</h1> <p>...</p> <p><a class="btn btn-primary btn-lg" role="button">Learn more</a></p> </div> <div class="dropdown"> <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown"> Dropdown <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1"> <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li> <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action</a></li> <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else here</a></li> <li role="presentation" class="divider"></li> <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a></li> </ul> </div> </body> </html> 

Eclipse version information is listed below. Spring Toolbox

Version: 3.6.1.RELEASE Build ID: 201408250818 Platform: Eclipse Luna (4.4)

Copyright (c) 2007 - 2014 Pivotal Software, Inc. All rights reserved. Visit http://spring.io/tools/sts

This product includes software developed by the Apache Software Foundation http://www.apache.org

+5
source share
2 answers

Your doctype

 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 

for HTML 4.01.

data-* attributes were added in HTML 5. The document for HTML 5 is basically either

 <!DOCTYPE html> 

or

 <!DOCTYPE html SYSTEM "about:legacy-compat"> 

It is also possible that your IDE does not know HTML 5 and its many changes.

+9
source

Newer versions of Eclipse support HTML5 tags and data- * attributes, which are allowed in HTML5. However, when using the role attribute, the correct syntax according to the ARIA Roles model and the XHTML role attribute module should not prefix the role attribute with the data - * leaving only the role and not the data role.

So, <ul role="menubar"> rather than <ul data-role="menubar"> . Syntax validation can be verified using (X) HTML5 Validator. jQuery Mobile uses the data-role attribute quite widely, although I'm not sure why.

Note. If you are updating and you still receive warnings about data- * attributes, you may want to update or remove any installed syntax checks, such as JTidy. Starting with version 1 of the Indigo service, the role attribute continues to trigger the warning of the undefined attribute in Eclipse by default.

0
source

Source: https://habr.com/ru/post/1204073/


All Articles