Question

I am trying to fill a form with values provided by the controller using tags in an app built with spring boot. But I get an error:

org.apache.jasper.JasperException: /WEB-INF/jsp/index.jsp (line: 52, column: 102) equal symbol expected

related part of index.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="en">
  <head>

    <title><spring:message code="title.main" /></title>

  </head>

  <body>
    <%@include file="include/navbar.jsp" %>

    <div class="container-fluid">
      <div class="row">
        <div class="col-sm-12 col-sm-offset-0 col-md-8 col-md-offset-2 main">
            <div class="panel panel-default">
                <div class="panel-body">
                    <form:form method="get" id="indexForm" commandName="indexForm" action="<c:url value="index_search" />" role="form">
                        <div class="row">
                            <div class="col-xs-6">
                                <div class="form-group">
                                    <label for="city_out"><spring:message code="label.index.0" /></label>
                                    <input:input type="text" class="form-control" id="city_out" path="city_out" />
                                </div>
                                <div class="form-group">
                                    <label for="city_in"><spring:message code="label.index.1" /></label>
                                    <form:input type="text" class="form-control" id="city_in" path="city_in" />
                                </div>
                                <div class="form-group">
                                    <label for="company"><spring:message code="label.index.2" /></label>
                                    <form:input type="text" class="form-control" id="company" path="company" />
                                </div>
                            </div>
                            <div class="col-xs-6">
                                <div class="form-group">
                                    <label for="date0"><spring:message code="label.index.3" /></label>
                                    <form:input type="datetime" class="form-control" placeholder="dd.MM.yyyy [HH:mm]" id="date0" path="date0" />
                                </div>
                                <div class="form-group">
                                    <label for="date1"><spring:message code="label.index.4" /></label>
                                    <form:input type="text" class="form-control" placeholder="dd.MM.yyyy [HH:mm]" id="date1" path="date1" />
                                </div>
                                <div class="form-group" align="right">
                                    <br />
                                    <button type="submit" id="search_btn" data-loading-text="Loading..." class="btn btn-primary">Search</button>
                                </div>
                            </div>
                        </div>
                    </form:form>

                </div>
            </div>
        </div>
      </div>
    </div>

  </body>
</html>

I have created a class to match form fields:

public class IndexForm {
    private String city_out;
    private String city_in;
    private String company;
    private String date0;
    private String date1;
// getters, setters
}

And created a bean in main class (I hope so):

@Configuration
@EnableAutoConfiguration
@ComponentScan
public class Application extends SpringBootServletInitializer {
    @Bean
    public static IndexForm indexForm() {
        return new IndexForm();
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(Application.class, args);
    }

}

Controller contains this method:

@RequestMapping("/index")
public String index(@RequestParam(value="e", required=false) List<Integer> errors, Map<String, Object> model) {
    model.put("indexForm", new IndexForm());
    if (errors != null)
        model.put("errors", errors);
    return "index";
}

I don't see any differences from examples I have seen, so I would be happy if someone pointed at my mistake.

Was it helpful?

Solution 2

Oh. It seems, including jsp tags one in another doesn't work. So, I changed

action="<c:url value="index_search" />" 

for

action="index_search" 

and received my page without errors.

OTHER TIPS

some newbies do a mistake by making the field as required in order to validate the field is filled or not e.g in normal html - input type="text" name="name" required

in spring - form:input path="firstName" required .... here required will not work and so same type of error "equal symbol expected".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top