403 error with controller via FreeMarker and spring403 Forbidden vs 401 Unauthorized HTTP responsesDownloading a file from spring controllersWhat's the difference between @Component, @Repository & @Service annotations in Spring?Spring MVC - Multiple submit button to a Formcakephp call action through buttonSpring boot + Freemarker + Bootstrap, submit form select option Entity as valueHow to change the base field of an Alfresco ftl (freemarker) control?Springboot+Freemarker: cannot properly send “select - option” value to controller from freemarker pageHow to call a method with a button in Freemarker DropWizardCSRF/Spring Security - 403 Error After Login via AJAX

Do moonless nights cause dim light to become darkness, and bright light (e.g. from torches) to become dim light?

Lower bound for the number of lattice points on high dimensional spheres

What is the most 'environmentally friendly' way to learn to fly?

What is Modern Vipassana?

Unlocked Package Dependencies

What is Albrecht Dürer's Perspective Machine drawing style?

Declaring a visitor to the UK as my "girlfriend" - effect on getting a Visitor visa?

Subtle ways to render a planet uninhabitable

How do people drown while wearing a life jacket?

How to avoid a lengthy conversation with someone from the neighborhood I don't share interests with

coding the arrow's path in flowchart

How was the cosmonaut of the Soviet moon mission supposed to get back in the return vehicle?

(7 of 11: Fillomino) What is Pyramid Cult's Favorite Shape?

How long should I wait to plug in my refrigerator after unplugging it?

Can an unintentional murderer leave Ir Miklat for Shalosh Regalim?

Have you been refused entry into the Federal Republic of Germany?

Does proof-of-work contribute directly to prevent double-spending?

Is it moral to remove/hide certain parts of a photo, as a photographer?

Can I say "Gesundheit" if someone is coughing?

Is an "are" omitted in this sentence

Why adjustbox needs a tweak of raise=-0.3ex with enumitem?

Why does the friction act on the inward direction when a car makes a turn on a level road?

What is it exactly about flying a Flyboard across the English channel that made Zapata's thighs burn?

How to understand "...to hide the evidence of mishandled magic, or else hidden by castle-proud house-elves" in this sentence



403 error with controller via FreeMarker and spring


403 Forbidden vs 401 Unauthorized HTTP responsesDownloading a file from spring controllersWhat's the difference between @Component, @Repository & @Service annotations in Spring?Spring MVC - Multiple submit button to a Formcakephp call action through buttonSpring boot + Freemarker + Bootstrap, submit form select option Entity as valueHow to change the base field of an Alfresco ftl (freemarker) control?Springboot+Freemarker: cannot properly send “select - option” value to controller from freemarker pageHow to call a method with a button in Freemarker DropWizardCSRF/Spring Security - 403 Error After Login via AJAX






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I've created page *.ftl with some tags and want to all this work with my specific controller.



I found that code written inside <#list el as set> cant get controller



This works






<div>
<form action="/deckStatusDel" method="post">
<input type="text" name="deckstatusid" value="$deckstatus1" />
<input type="hidden" value="$deck.id" name="deckId">
<input type="hidden" name="_csrf" value="$_csrf.token" />
<button type="submit">Delete status</button>
</form>
</div>





This doesn't






<#list deck_statuses as deck_status>
<div>
<form action="/deckStatusDel" method="post">
<input type="text" value="$deck_status.id" name="deckstatusid">
<span>$deck_status.status</span>
<button type="submit">Delete status</button>
</form>
</div>
<#else>
empty
</#list>





Controller code






@PostMapping("/deckStatusDel")
public String deckStatusDelete(
@RequestParam Long deckstatusid,
@RequestParam("deckId") Deck deck
)
deckStatusesRepo.deleteById(deckstatusid);
return "redirect:/deck/"+deck.getId();





The code from the list is getting and sending the correct id, but i get 403 error. Why?










share|improve this question


























  • Thank you so much. I'm so inconsiderate

    – tkalin.vladimir
    Mar 27 at 2:53

















1















I've created page *.ftl with some tags and want to all this work with my specific controller.



I found that code written inside <#list el as set> cant get controller



This works






<div>
<form action="/deckStatusDel" method="post">
<input type="text" name="deckstatusid" value="$deckstatus1" />
<input type="hidden" value="$deck.id" name="deckId">
<input type="hidden" name="_csrf" value="$_csrf.token" />
<button type="submit">Delete status</button>
</form>
</div>





This doesn't






<#list deck_statuses as deck_status>
<div>
<form action="/deckStatusDel" method="post">
<input type="text" value="$deck_status.id" name="deckstatusid">
<span>$deck_status.status</span>
<button type="submit">Delete status</button>
</form>
</div>
<#else>
empty
</#list>





Controller code






@PostMapping("/deckStatusDel")
public String deckStatusDelete(
@RequestParam Long deckstatusid,
@RequestParam("deckId") Deck deck
)
deckStatusesRepo.deleteById(deckstatusid);
return "redirect:/deck/"+deck.getId();





The code from the list is getting and sending the correct id, but i get 403 error. Why?










share|improve this question


























  • Thank you so much. I'm so inconsiderate

    – tkalin.vladimir
    Mar 27 at 2:53













1












1








1








I've created page *.ftl with some tags and want to all this work with my specific controller.



I found that code written inside <#list el as set> cant get controller



This works






<div>
<form action="/deckStatusDel" method="post">
<input type="text" name="deckstatusid" value="$deckstatus1" />
<input type="hidden" value="$deck.id" name="deckId">
<input type="hidden" name="_csrf" value="$_csrf.token" />
<button type="submit">Delete status</button>
</form>
</div>





This doesn't






<#list deck_statuses as deck_status>
<div>
<form action="/deckStatusDel" method="post">
<input type="text" value="$deck_status.id" name="deckstatusid">
<span>$deck_status.status</span>
<button type="submit">Delete status</button>
</form>
</div>
<#else>
empty
</#list>





Controller code






@PostMapping("/deckStatusDel")
public String deckStatusDelete(
@RequestParam Long deckstatusid,
@RequestParam("deckId") Deck deck
)
deckStatusesRepo.deleteById(deckstatusid);
return "redirect:/deck/"+deck.getId();





The code from the list is getting and sending the correct id, but i get 403 error. Why?










share|improve this question
















I've created page *.ftl with some tags and want to all this work with my specific controller.



I found that code written inside <#list el as set> cant get controller



This works






<div>
<form action="/deckStatusDel" method="post">
<input type="text" name="deckstatusid" value="$deckstatus1" />
<input type="hidden" value="$deck.id" name="deckId">
<input type="hidden" name="_csrf" value="$_csrf.token" />
<button type="submit">Delete status</button>
</form>
</div>





This doesn't






<#list deck_statuses as deck_status>
<div>
<form action="/deckStatusDel" method="post">
<input type="text" value="$deck_status.id" name="deckstatusid">
<span>$deck_status.status</span>
<button type="submit">Delete status</button>
</form>
</div>
<#else>
empty
</#list>





Controller code






@PostMapping("/deckStatusDel")
public String deckStatusDelete(
@RequestParam Long deckstatusid,
@RequestParam("deckId") Deck deck
)
deckStatusesRepo.deleteById(deckstatusid);
return "redirect:/deck/"+deck.getId();





The code from the list is getting and sending the correct id, but i get 403 error. Why?






<div>
<form action="/deckStatusDel" method="post">
<input type="text" name="deckstatusid" value="$deckstatus1" />
<input type="hidden" value="$deck.id" name="deckId">
<input type="hidden" name="_csrf" value="$_csrf.token" />
<button type="submit">Delete status</button>
</form>
</div>





<div>
<form action="/deckStatusDel" method="post">
<input type="text" name="deckstatusid" value="$deckstatus1" />
<input type="hidden" value="$deck.id" name="deckId">
<input type="hidden" name="_csrf" value="$_csrf.token" />
<button type="submit">Delete status</button>
</form>
</div>





<#list deck_statuses as deck_status>
<div>
<form action="/deckStatusDel" method="post">
<input type="text" value="$deck_status.id" name="deckstatusid">
<span>$deck_status.status</span>
<button type="submit">Delete status</button>
</form>
</div>
<#else>
empty
</#list>





<#list deck_statuses as deck_status>
<div>
<form action="/deckStatusDel" method="post">
<input type="text" value="$deck_status.id" name="deckstatusid">
<span>$deck_status.status</span>
<button type="submit">Delete status</button>
</form>
</div>
<#else>
empty
</#list>





@PostMapping("/deckStatusDel")
public String deckStatusDelete(
@RequestParam Long deckstatusid,
@RequestParam("deckId") Deck deck
)
deckStatusesRepo.deleteById(deckstatusid);
return "redirect:/deck/"+deck.getId();





@PostMapping("/deckStatusDel")
public String deckStatusDelete(
@RequestParam Long deckstatusid,
@RequestParam("deckId") Deck deck
)
deckStatusesRepo.deleteById(deckstatusid);
return "redirect:/deck/"+deck.getId();






java spring controller freemarker http-status-code-403






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 29 at 5:30









user7294900

29.2k12 gold badges40 silver badges73 bronze badges




29.2k12 gold badges40 silver badges73 bronze badges










asked Mar 27 at 1:16









tkalin.vladimirtkalin.vladimir

82 bronze badges




82 bronze badges















  • Thank you so much. I'm so inconsiderate

    – tkalin.vladimir
    Mar 27 at 2:53

















  • Thank you so much. I'm so inconsiderate

    – tkalin.vladimir
    Mar 27 at 2:53
















Thank you so much. I'm so inconsiderate

– tkalin.vladimir
Mar 27 at 2:53





Thank you so much. I'm so inconsiderate

– tkalin.vladimir
Mar 27 at 2:53












1 Answer
1






active

oldest

votes


















0














In the second form you are missing a csrf token for authentication



<input type="hidden" name="_csrf" value="$_csrf.token" />





share|improve this answer


























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55368401%2f403-error-with-controller-via-freemarker-and-spring%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    In the second form you are missing a csrf token for authentication



    <input type="hidden" name="_csrf" value="$_csrf.token" />





    share|improve this answer































      0














      In the second form you are missing a csrf token for authentication



      <input type="hidden" name="_csrf" value="$_csrf.token" />





      share|improve this answer





























        0












        0








        0







        In the second form you are missing a csrf token for authentication



        <input type="hidden" name="_csrf" value="$_csrf.token" />





        share|improve this answer















        In the second form you are missing a csrf token for authentication



        <input type="hidden" name="_csrf" value="$_csrf.token" />






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 27 at 3:59

























        answered Mar 27 at 3:32









        user7294900user7294900

        29.2k12 gold badges40 silver badges73 bronze badges




        29.2k12 gold badges40 silver badges73 bronze badges





















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55368401%2f403-error-with-controller-via-freemarker-and-spring%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript