whitehat
whitehat

Reputation: 2391

URI for using Java Spring Tags

Inorder to use Spring Form Tags in JSP file following is taglib element I added :-

    <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>

And I used this reference for the same.

However, Eclipse is not able to find the Tag Library Desciptor file. What is the correct URI?

Upvotes: 5

Views: 14099

Answers (4)

Ansh Vikalp
Ansh Vikalp

Reputation: 1

Your Page directive is correct

<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>

but make sure that you correctly use the form tag and there should be no space between <form:form ...> or <form:input ...>

Below code is incorrect:-

<form: form action="InsertDepartment" meathod="post" modelAttribute="department">
            Enter Department No:
            <form: input path="deptno" /><br>
            Enter Department Name:
            <form: input path="dname" /> <br>
            Enter Department Location:
            <form: input path="loc" /><br>

            <input type="submit" value="SUBMIT" />

        </form: form>

Correct Code:-

<form:form action="InsertDepartment" meathod="post" modelAttribute="department">
            Enter Department No:
            <form:input path="deptno" /><br>
            Enter Department Name:
            <form:input path="dname" /> <br>
            Enter Department Location:
            <form:input path="loc" /><br>

            <input type="submit" value="SUBMIT" />

        </form:form>

Upvotes: 0

mprabhat
mprabhat

Reputation: 20323

Can you make sure you have some form of Spring Servlet jar in your eclipse classpath. Name should be like org.springframework.web.servlet-3.1.0.M1 if you are using Spring 3, this should be present under your dist folder in Spring distribution or else spring-webmvc.jar

Upvotes: 0

Adam Gent
Adam Gent

Reputation: 49075

The uri is correct.

Make sure:

  • You have the Eclipse plugin Web Tools Project (WTP) installed
  • You have all the Spring jars in your build path
  • That the project has the facet "Dynamic Web Module" (go to Project Facets)
  • Make sure that it is a JSP file and not a JSPX

If its JSPX the notation would look more like:

<html xmlns:jsp="http://java.sun.com/JSP/Page"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:tiles="http://tiles.apache.org/tags-tiles"
      xmlns:form="http://www.springframework.org/tags/form"
      xmlns:spring="http://www.springframework.org/tags"
      xmlns:util="urn:jsptagdir:/WEB-INF/tags/util"> 

Upvotes: 4

komfitura
komfitura

Reputation: 63

Sounds correct. Something like:

<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

should work. Are you sure you have spring-webmvc jar on your classpath?

Upvotes: 2

Related Questions