text
stringlengths
400
1.13k
<s>[INST] Convert the following Struts action method to a Spring Boot controller method. public class MyAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Struts action code here return mapping.findForward("success"); } } [/INST] @RestController @RequestMapping("/myAction") public class MyController { @GetMapping public String execute() { // Spring Boot controller code here return "success"; } } </s>
<s>[INST] Convert the following Struts form bean to a Spring Boot form backing object. public class MyForm extends ActionForm { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } } [/INST] public class MyForm { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } } </s>
<s>[INST] Convert the following Struts action forward to a Spring Boot controller method. <action path="/submitForm" type="com.example.SubmitAction" name="myForm" scope="request" input="/input.jsp"> <forward name="success" path="/success.jsp" /> </action> [/INST] @RestController @RequestMapping("/submitForm") public class SubmitController { @PostMapping public String submitForm(@ModelAttribute MyForm myForm) { // Spring Boot form submission code here return "success"; } } </s>
<s>[INST] Convert the following Struts validation code to Spring Boot validation. public class MyForm extends ActionForm { private String email; public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if (email == null || !email.contains("@")) { errors.add("email", new ActionMessage("error.email.invalid")); } return errors; } } [/INST] public class MyForm { @NotNull @Email private String email; } @RestController @RequestMapping("/myForm") public class MyFormController { @PostMapping public String submitForm(@Valid @ModelAttribute MyForm myForm, BindingResult result) { if (result.hasErrors()) { return "form"; } return "success"; } } </s>
<s>[INST] Convert the following Struts configuration to Spring Boot controller. <action-mappings> <action path="/login" type="com.example.LoginAction" name="loginForm" scope="request" input="/login.jsp"> <forward name="success" path="/home.jsp" /> <forward name="failure" path="/login.jsp" /> </action> </action-mappings> [/INST] @RestController @RequestMapping("/login") public class LoginController { @PostMapping public String login(@ModelAttribute LoginForm loginForm) { // Login logic here if (/* login successful */) { return "home"; } else { return "login"; } } } </s>
<s>[INST] Convert the following Struts form reset method to a Spring Boot initialization method. public class MyForm extends ActionForm { private String name; public void reset(ActionMapping mapping, HttpServletRequest request) { this.name = null; } } [/INST] @RestController @RequestMapping("/myForm") public class MyFormController { @ModelAttribute public MyForm setupForm() { MyForm form = new MyForm(); form.setName(null); return form; } } </s>
<s>[INST] Convert the following Struts use of session scope to Spring Boot session attributes. public class MyAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession session = request.getSession(); session.setAttribute("user", form); return mapping.findForward("success"); } } [/INST] @RestController @SessionAttributes("user") @RequestMapping("/myAction") public class MyController { @PostMapping public String execute(@ModelAttribute("user") MyForm form) { // Spring Boot session handling code here return "success"; } } </s>
<s>[INST] Convert the following Struts tiles definition to a Spring Boot tiles definition. <definition name="baseLayout" path="/WEB-INF/tiles/layout.jsp"> <put-attribute name="header" value="/WEB-INF/tiles/header.jsp" /> <put-attribute name="body" value="/WEB-INF/tiles/body.jsp" /> <put-attribute name="footer" value="/WEB-INF/tiles/footer.jsp" /> </definition> [/INST] <definition name="baseLayout" template="/WEB-INF/tiles/layout.jsp"> <put-attribute name="header" value="/WEB-INF/tiles/header.jsp" /> <put-attribute name="body" value="/WEB-INF/tiles/body.jsp" /> <put-attribute name="footer" value="/WEB-INF/tiles/footer.jsp" /> </definition> </s>
<s>[INST] Convert the following Struts use of request scope to Spring Boot request attributes. public class MyAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { request.setAttribute("message", "Hello World"); return mapping.findForward("success"); } } [/INST] @RestController @RequestMapping("/myAction") public class MyController { @GetMapping public String execute(Model model) { model.addAttribute("message", "Hello World"); return "success"; } } </s>
<s>[INST] Convert the following Struts global exception handling to Spring Boot global exception handling. <global-exceptions> <exception key="error" type="java.lang.Exception" path="/error.jsp" /> </global-exceptions> [/INST] @ControllerAdvice public class GlobalExceptionHandler { @ExceptionHandler(Exception.class) public String handleException() { return "error"; } } </s>
<s>[INST] Convert the following Struts forward to a Spring Boot redirect. <action path="/logout" type="com.example.LogoutAction"> <forward name="success" path="/login.jsp" redirect="true" /> </action> [/INST] @RestController @RequestMapping("/logout") public class LogoutController { @GetMapping public String logout() { // Logout logic here return "redirect:/login"; } } </s>
<s>[INST] Convert the following Struts module-based action configuration to Spring Boot configuration with controller-based paths. <action-mappings> <action path="/user/view" type="com.example.user.ViewUserAction" /> <action path="/user/edit" type="com.example.user.EditUserAction" /> </action-mappings> [/INST] @RestController @RequestMapping("/user") public class UserController { @GetMapping("/view") public String viewUser() { // View user logic here return "viewUser"; } @GetMapping("/edit") public String editUser() { // Edit user logic here return "editUser"; } } </s>
<s>[INST] Convert the following Struts action mapping with multiple forwards to a Spring Boot controller with multiple request mappings. <action path="/processForm" type="com.example.ProcessFormAction"> <forward name="success" path="/success.jsp" /> <forward name="failure" path="/failure.jsp" /> </action> [/INST] @RestController @RequestMapping("/processForm") public class ProcessFormController { @PostMapping public String processForm(@ModelAttribute MyForm myForm, Model model) { // Form processing logic here if (/* success condition */) { return "success"; } else { return "failure"; } } } </s>
<s>[INST] Convert the following Struts action configuration with input path to a Spring Boot controller. <action path="/submitForm" type="com.example.SubmitFormAction" input="/input.jsp"> <forward name="success" path="/success.jsp" /> </action> [/INST] @RestController @RequestMapping("/submitForm") public class SubmitFormController { @PostMapping public String submitForm(@ModelAttribute MyForm myForm, BindingResult result) { if (result.hasErrors()) { return "input"; } // Form submission logic here return "success"; } } </s>
<s>[INST] Convert the following Struts use of ActionErrors to Spring Boot error handling with BindingResult. public class MyForm extends ActionForm { private String name; public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if (name == null || name.isEmpty()) { errors.add("name", new ActionMessage("error.name.required")); } return errors; } } [/INST] public class MyForm { @NotNull @NotEmpty private String name; } @RestController @RequestMapping("/myForm") public class MyFormController { @PostMapping public String submitForm(@Valid @ModelAttribute MyForm myForm, BindingResult result) { if (result.hasErrors()) { return "form"; } return "success"; } } </s>
<s>[INST] Convert the following Struts action with dependency injection to a Spring Boot controller with dependency injection. public class MyAction extends Action { private MyService myService; public void setMyService(MyService myService) { this.myService = myService; } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { myService.doSomething(); return mapping.findForward("success"); } } [/INST] @RestController @RequestMapping("/myAction") public class MyController { private final MyService myService; @Autowired public MyController(MyService myService) { this.myService = myService; } @GetMapping public String execute() { myService.doSomething(); return "success"; } } </s>
<s>[INST] Convert the following Struts action form validation to Spring Boot validation with @Valid. public class LoginForm extends ActionForm { private String username; private String password; public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if (username == null || username.isEmpty()) { errors.add("username", new ActionMessage("error.username.required")); } if (password == null || password.isEmpty()) { errors.add("password", new ActionMessage("error.password.required")); } return errors; } } [/INST] public class LoginForm { @NotNull @NotEmpty private String username; @NotNull @NotEmpty private String password; } @RestController @RequestMapping("/login") public class LoginController { @PostMapping public String login(@Valid @ModelAttribute LoginForm loginForm, BindingResult result) { if (result.hasErrors()) { return "login"; } // Login logic here return "home"; } } </s>
<s>[INST] Convert the following Struts action with a session scope form to a Spring Boot controller with session attributes. public class MyAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession session = request.getSession(); session.setAttribute("userForm", form); return mapping.findForward("success"); } } [/INST] @RestController @SessionAttributes("userForm") @RequestMapping("/myAction") public class MyController { @PostMapping public String execute(@ModelAttribute("userForm") UserForm form) { // Session handling logic here return "success"; } } </s>
<s>[INST] Convert the following Struts action with a request scope form to a Spring Boot controller with request attributes. public class MyAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { request.setAttribute("message", "Hello, " + form.getName()); return mapping.findForward("success"); } } [/INST] @RestController @RequestMapping("/myAction") public class MyController { @PostMapping public String execute(@ModelAttribute MyForm form, Model model) { model.addAttribute("message", "Hello, " + form.getName()); return "success"; } } </s>
<s>[INST] Convert the following Struts use of ActionMessages to Spring Boot error handling with BindingResult. public class MyForm extends ActionForm { private String email; public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if (email == null || !email.contains("@")) { errors.add("email", new ActionMessage("error.email.invalid")); } return errors; } } [/INST] public class MyForm { @NotNull @Email private String email; } @RestController @RequestMapping("/myForm") public class MyFormController { @PostMapping public String submitForm(@Valid @ModelAttribute MyForm myForm, BindingResult result) { if (result.hasErrors()) { return "form"; } return "success"; } } </s>
<s>[INST] Convert the following Struts use of ActionForms to Spring Boot @ModelAttribute. public class MyForm extends ActionForm { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } } [/INST] public class MyForm { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } } @RestController @RequestMapping("/myForm") public class MyFormController { @PostMapping public String submitForm(@ModelAttribute MyForm myForm) { // Form submission logic here return "success"; } } </s>
<s>[INST] Convert the following Struts use of ActionForward to Spring Boot @GetMapping. public class MyAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { return mapping.findForward("success"); } } [/INST] @RestController @RequestMapping("/myAction") public class MyController { @GetMapping public String execute() { return "success"; } } </s>
<s>[INST] Convert the following Struts use of ActionForm validation to Spring Boot validation with @Valid. public class MyForm extends ActionForm { private String username; private String password; public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if (username == null || username.isEmpty()) { errors.add("username", new ActionMessage("error.username.required")); } if (password == null || password.isEmpty()) { errors.add("password", new ActionMessage("error.password.required")); } return errors; } } [/INST] public class MyForm { @NotNull @NotEmpty private String username; @NotNull @NotEmpty private String password; } @RestController @RequestMapping("/myForm") public class MyFormController { @PostMapping public String submitForm(@Valid @ModelAttribute MyForm myForm, BindingResult result) { if (result.hasErrors()) { return "form"; } return "success"; } } </s>
<s>[INST] Convert the following Struts action mapping with validation to a Spring Boot controller with validation. <action path="/register" type="com.example.RegisterAction" name="registerForm" scope="request" input="/register.jsp"> <forward name="success" path="/welcome.jsp" /> </action> [/INST] public class RegisterForm { @NotNull @NotEmpty private String username; @NotNull @NotEmpty private String password; } @RestController @RequestMapping("/register") public class RegisterController { @PostMapping public String register(@Valid @ModelAttribute RegisterForm registerForm, BindingResult result) { if (result.hasErrors()) { return "register"; } // Registration logic here return "welcome"; } } </s>
<s>[INST] Convert the following Struts action with forward to a Spring Boot controller with return value. <action path="/process" type="com.example.ProcessAction"> <forward name="success" path="/result.jsp" /> </action> [/INST] @RestController @RequestMapping("/process") public class ProcessController { @PostMapping public String process() { // Processing logic here return "result"; } } </s>
<s>[INST] Convert the following Struts use of request scope ActionForms to Spring Boot @ModelAttribute. public class MyForm extends ActionForm { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } } [/INST] public class MyForm { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } } @RestController @RequestMapping("/myForm") public class MyFormController { @PostMapping public String submitForm(@ModelAttribute MyForm myForm) { // Form submission logic here return "success"; } } </s>
<s>[INST] Convert the following Struts action mapping with validation and input path to a Spring Boot controller. <action path="/update" type="com.example.UpdateAction" name="updateForm" scope="request" input="/update.jsp"> <forward name="success" path="/details.jsp" /> </action> [/INST] public class UpdateForm { @NotNull @NotEmpty private String name; } @RestController @RequestMapping("/update") public class UpdateController { @PostMapping public String update(@Valid @ModelAttribute UpdateForm updateForm, BindingResult result) { if (result.hasErrors()) { return "update"; } // Update logic here return "details"; } } </s>
<s>[INST] Convert the following Struts action mapping with multiple forwards to a Spring Boot controller with multiple return values. <action path="/delete" type="com.example.DeleteAction"> <forward name="success" path="/list.jsp" /> <forward name="failure" path="/error.jsp" /> </action> [/INST] @RestController @RequestMapping("/delete") public class DeleteController { @PostMapping public String delete() { // Deletion logic here if (/* success condition */) { return "list"; } else { return "error"; } } } </s>
<s>[INST] Convert the following Struts action mapping with session scope form to a Spring Boot controller with session attributes. <action path="/profile" type="com.example.ProfileAction" scope="session"> <forward name="success" path="/profile.jsp" /> </action> [/INST] @RestController @SessionAttributes("profileForm") @RequestMapping("/profile") public class ProfileController { @PostMapping public String profile(@ModelAttribute("profileForm") ProfileForm form) { // Profile logic here return "profile"; } } </s>
<s>[INST] Convert the following Struts use of ActionForm validation to Spring Boot validation with @Valid. public class RegisterForm extends ActionForm { private String username; private String password; public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if (username == null || username.isEmpty()) { errors.add("username", new ActionMessage("error.username.required")); } if (password == null || password.isEmpty()) { errors.add("password", new ActionMessage("error.password.required")); } return errors; } } [/INST] public class RegisterForm { @NotNull @NotEmpty private String username; @NotNull @NotEmpty private String password; } @RestController @RequestMapping("/register") public class RegisterController { @PostMapping public String register(@Valid @ModelAttribute RegisterForm registerForm, BindingResult result) { if (result.hasErrors()) { return "register"; } return "welcome"; } } </s>
<s>[INST] Convert the following Struts action with request scope form to a Spring Boot controller with request attributes. public class MyAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { request.setAttribute("message", "Hello, " + form.getName()); return mapping.findForward("success"); } } [/INST] @RestController @RequestMapping("/myAction") public class MyController { @PostMapping public String execute(@ModelAttribute MyForm form, Model model) { model.addAttribute("message", "Hello, " + form.getName()); return "success"; } } </s>
<s>[INST] Convert the following Struts action mapping with multiple forwards to a Spring Boot controller with multiple return values. <action path="/save" type="com.example.SaveAction"> <forward name="success" path="/list.jsp" /> <forward name="failure" path="/form.jsp" /> </action> [/INST] @RestController @RequestMapping("/save") public class SaveController { @PostMapping public String save(@ModelAttribute MyForm form) { // Save logic here if (/* success condition */) { return "list"; } else { return "form"; } } } </s>
<s>[INST] Convert the following Struts action mapping with validation to a Spring Boot controller with validation. <action path="/create" type="com.example.CreateAction" name="createForm" scope="request" input="/create.jsp"> <forward name="success" path="/detail.jsp" /> </action> [/INST] public class CreateForm { @NotNull @NotEmpty private String name; } @RestController @RequestMapping("/create") public class CreateController { @PostMapping public String create(@Valid @ModelAttribute CreateForm createForm, BindingResult result) { if (result.hasErrors()) { return "create"; } // Creation logic here return "detail"; } } </s>
<s>[INST] Convert the following Struts action mapping with session scope form to a Spring Boot controller with session attributes. <action path="/editProfile" type="com.example.EditProfileAction" scope="session"> <forward name="success" path="/profile.jsp" /> </action> [/INST] @RestController @SessionAttributes("editProfileForm") @RequestMapping("/editProfile") public class EditProfileController { @PostMapping public String editProfile(@ModelAttribute("editProfileForm") EditProfileForm form) { // Edit profile logic here return "profile"; } } </s>
<s>[INST] Convert the following Struts action mapping with input path to a Spring Boot controller with return values. <action path="/submit" type="com.example.SubmitAction" input="/input.jsp"> <forward name="success" path="/result.jsp" /> </action> [/INST] @RestController @RequestMapping("/submit") public class SubmitController { @PostMapping public String submit(@ModelAttribute MyForm form, BindingResult result) { if (result.hasErrors()) { return "input"; } // Submission logic here return "result"; } } </s>
README.md exists but content is empty. Use the Edit dataset card button to edit it.
Downloads last month
33
Edit dataset card