OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Getting Error "This application has no explicit mapping for /error, so you are seeing this as a fallback. (type=Internal Server Error, status=500). "

  • Thread starter Thread starter TuShar ThAkre
  • Start date Start date
T

TuShar ThAkre

Guest
Getting this error :

Exception processing template "index": Exception evaluating SpringEL expression: "bookingForm.name" (template: "index" - line 139, col 29)

org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "bookingForm.name" (template: "index"

  • line 139, col 29) at org.thymeleaf.spring6.expression.SPELVariableExpressionEvaluator.evaluate(SPELVariableExpressionEvaluator.java:292) ~[thymeleaf-spring6-3.1.2.RELEASE.jar:3.1.2.RELEASE]

Code:
<h3>Booking Form</h3>
<form id="bookingForm" th:action="@{bookingform}" th:object="${bookingForm}" method="post">
    <div class="fl1">
        <div class="tmInput">
            <input name="name" th:value="${bookingForm.name}" placeHolder="Name:" type="text">
            <span style="color: red;" th:if="${#fields.hasErrors('name')}" th:errors="*{name}"></span>
        </div>
        <div class="tmInput">
            <input name="from" th:value="${bookingForm.from}" placeHolder="Source:" type="text">
            <span style="color: red;" th:if="${#fields.hasErrors('from')}" th:errors="*{from}"></span>
        </div>
    </div>
    <div class="fl1">
        <div class="tmInput">
            <input name="email" th:value="${bookingForm.email}" placeHolder="Email:" type="email">
            <span style="color: red;" th:if="${#fields.hasErrors('email')}" th:errors="*{email}"></span>
        </div>
        <div class="tmInput mr0">
            <input name="to" th:value="${bookingForm.to}" placeHolder="Destination:" type="text">
            <span style="color: red;" th:if="${#fields.hasErrors('to')}" th:errors="*{to}"></span>
        </div>
    </div>
    <div class="clear"></div>
    <strong>Time</strong>
    <div class="tmInput">
        <input name="time" th:value="${bookingForm.time}" placeHolder="" type="time">
        <span style="color: red;" th:if="${#fields.hasErrors('from')}" th:errors="*{from}"></span>
    </div>
    <div class="clear"></div>
    <strong>Date</strong>
    <label>
        <input type="date" name="date" th:value="${bookingForm.date}" placeHolder='20/05/2014'>
        <span style="color: red;" th:if="${#fields.hasErrors('date')}" th:errors="*{date}"></span>
    </label>

    <!-- <span style="color: red;" th:if="${#fields.hasErrors('comfort')}" th:errors="*{comfort}"></span> -->
    <div class="clear"></div>
    <div class="tmRadio">
        <p>Comfort</p>
        <span style="color: red;" th:if="${#fields.hasErrors('comfort')}" th:errors="*{comfort}"></span>
        <div class="clear"></div>
        <input name="comfort" value="cheap" th:checked="${bookingForm.comfort=='cheap'}" type="radio" id="tmRadio0" />
        <span>Cheap</span>
        <input name="comfort" value="standard" th:checked="${bookingForm.comfort=='standard'}" type="radio"
            id="tmRadio1" />

        <span>Standard</span>
        <input name="comfort" value="lux" th:checked="${bookingForm.comfort=='lux'}" type="radio" id="tmRadio2" />


        <span>Lux</span>

    </div>
    <div class="clear"></div>
    <span style="color: red;" th:if="${#fields.hasErrors('adult')}" th:errors="*{adult}"></span>
    <div class="fl1 fl2">
        <em>Adults</em>
        <select name="adult" class="tmSelect auto" data-class="tmSelect tmSelect2" data-constraints="">
            <option>1</option>

            <option>2</option>
            <option>3</option>
            <option>4</option>
        </select>
        <div class="clear height1"></div>
    </div>
    <span style="color: red;" th:if="${#fields.hasErrors('children')}" th:errors="*{childre}"></span>
    <div class="fl1 fl2">
        <em>Children</em>
        <select name="children" class="tmSelect auto" data-class="tmSelect tmSelect2">
            <option>0</option>
            <option>1</option>
            <option>2</option>
            <option>3</option>
        </select>
    </div>
    <div class="clear"></div>
    <div class="tmTextarea">
        <textarea name="message" th:text="${bookingForm.message}" placeHolder="Message"></textarea>
        <span style="color: red;" th:if="${#fields.hasErrors('message')}" th:errors="*{message}"></span>
    </div>
    <button class="btn">Submit</button>
</form>

Here Is my Controller##​


Code:
@RestController
public class MyController 
{

    private ContactFormServiceImpl contactFormServiceImpl;

     @Autowired
    public void setContactFormServiceImpl(ContactFormServiceImpl contactFormServiceImpl) {
        this.contactFormServiceImpl = contactFormServiceImpl;
    }


      //Booking Form

    @GetMapping(path={"","home","welcome","index"})
    public String welcomeView(Model m)
    {
        m.addAttribute("bookingForm",new BookingForm() );
        return"index";
    }

    @PostMapping("bookingform")
    public String bookingForm(@Valid @ModelAttribute("bookingForm") BookingForm bookingForm, BindingResult bindingResult, Model m)
    {
        if (bindingResult.hasErrors()) 
        {
            m.addAttribute("bindingResult", bindingResult);
            return "index";
        }
        System.out.println(bookingForm);
        return "redirect:/index";
    }
}
<p>Getting this error :</p>
<blockquote>
<p>Exception processing template "index": Exception evaluating SpringEL
expression: "bookingForm.name" (template: "index" - line 139, col 29)</p>
<p>org.thymeleaf.exceptions.TemplateProcessingException: Exception
evaluating SpringEL expression: "bookingForm.name" (template: "index"</p>
<ul>
<li>line 139, col 29)
at org.thymeleaf.spring6.expression.SPELVariableExpressionEvaluator.evaluate(SPELVariableExpressionEvaluator.java:292)
~[thymeleaf-spring6-3.1.2.RELEASE.jar:3.1.2.RELEASE]</li>
</ul>
</blockquote>
<pre class="lang-html prettyprint-override"><code><h3>Booking Form</h3>
<form id="bookingForm" th:action="@{bookingform}" th:object="${bookingForm}" method="post">
<div class="fl1">
<div class="tmInput">
<input name="name" th:value="${bookingForm.name}" placeHolder="Name:" type="text">
<span style="color: red;" th:if="${#fields.hasErrors('name')}" th:errors="*{name}"></span>
</div>
<div class="tmInput">
<input name="from" th:value="${bookingForm.from}" placeHolder="Source:" type="text">
<span style="color: red;" th:if="${#fields.hasErrors('from')}" th:errors="*{from}"></span>
</div>
</div>
<div class="fl1">
<div class="tmInput">
<input name="email" th:value="${bookingForm.email}" placeHolder="Email:" type="email">
<span style="color: red;" th:if="${#fields.hasErrors('email')}" th:errors="*{email}"></span>
</div>
<div class="tmInput mr0">
<input name="to" th:value="${bookingForm.to}" placeHolder="Destination:" type="text">
<span style="color: red;" th:if="${#fields.hasErrors('to')}" th:errors="*{to}"></span>
</div>
</div>
<div class="clear"></div>
<strong>Time</strong>
<div class="tmInput">
<input name="time" th:value="${bookingForm.time}" placeHolder="" type="time">
<span style="color: red;" th:if="${#fields.hasErrors('from')}" th:errors="*{from}"></span>
</div>
<div class="clear"></div>
<strong>Date</strong>
<label>
<input type="date" name="date" th:value="${bookingForm.date}" placeHolder='20/05/2014'>
<span style="color: red;" th:if="${#fields.hasErrors('date')}" th:errors="*{date}"></span>
</label>

<!-- <span style="color: red;" th:if="${#fields.hasErrors('comfort')}" th:errors="*{comfort}"></span> -->
<div class="clear"></div>
<div class="tmRadio">
<p>Comfort</p>
<span style="color: red;" th:if="${#fields.hasErrors('comfort')}" th:errors="*{comfort}"></span>
<div class="clear"></div>
<input name="comfort" value="cheap" th:checked="${bookingForm.comfort=='cheap'}" type="radio" id="tmRadio0" />
<span>Cheap</span>
<input name="comfort" value="standard" th:checked="${bookingForm.comfort=='standard'}" type="radio"
id="tmRadio1" />

<span>Standard</span>
<input name="comfort" value="lux" th:checked="${bookingForm.comfort=='lux'}" type="radio" id="tmRadio2" />


<span>Lux</span>

</div>
<div class="clear"></div>
<span style="color: red;" th:if="${#fields.hasErrors('adult')}" th:errors="*{adult}"></span>
<div class="fl1 fl2">
<em>Adults</em>
<select name="adult" class="tmSelect auto" data-class="tmSelect tmSelect2" data-constraints="">
<option>1</option>

<option>2</option>
<option>3</option>
<option>4</option>
</select>
<div class="clear height1"></div>
</div>
<span style="color: red;" th:if="${#fields.hasErrors('children')}" th:errors="*{childre}"></span>
<div class="fl1 fl2">
<em>Children</em>
<select name="children" class="tmSelect auto" data-class="tmSelect tmSelect2">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
</div>
<div class="clear"></div>
<div class="tmTextarea">
<textarea name="message" th:text="${bookingForm.message}" placeHolder="Message"></textarea>
<span style="color: red;" th:if="${#fields.hasErrors('message')}" th:errors="*{message}"></span>
</div>
<button class="btn">Submit</button>
</form>
</code></pre>
<h3>Here Is my Controller##</h3>
<pre class="lang-java prettyprint-override"><code>@RestController
public class MyController
{

private ContactFormServiceImpl contactFormServiceImpl;

@Autowired
public void setContactFormServiceImpl(ContactFormServiceImpl contactFormServiceImpl) {
this.contactFormServiceImpl = contactFormServiceImpl;
}


//Booking Form

@GetMapping(path={"","home","welcome","index"})
public String welcomeView(Model m)
{
m.addAttribute("bookingForm",new BookingForm() );
return"index";
}

@PostMapping("bookingform")
public String bookingForm(@Valid @ModelAttribute("bookingForm") BookingForm bookingForm, BindingResult bindingResult, Model m)
{
if (bindingResult.hasErrors())
{
m.addAttribute("bindingResult", bindingResult);
return "index";
}
System.out.println(bookingForm);
return "redirect:/index";
}
}
</code></pre>
Continue reading...
 

Latest posts

Top